Passing Console output from java to jsp
Step 1: Create Hello.java and paste the below code,
[java]package com.agn;
public class Hello {
/**
* @param args
*/
public String returning(){
String go = "hello Naveen";
return go;
}
public static void main(String[] args) {
Hello h = new Hello();
System.out.println(h.returning());
}
}[/java]
Step 2: Create fethingfromjava.jsp and paste the below code,
[html]<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%@ page import="com.agn.Hello" %>
<% Hello hjsp = new Hello();
String got = hjsp.returning();
out.println(got);
%>
</body>
</html>[/html]
Step 3: Ouput
You can see Hello Naveen output in jsp page.