Passing Console output from java to jsp

Passing Console output from java to jsp

Step 1: Create Hello.java and paste the below code,

 

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());
	}

}

 

Step 2: Create fethingfromjava.jsp and paste the below code,

 

<%@ 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>

 

Step 3: Ouput

You can see Hello Naveen output in jsp page.

2,874 total views, 1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *