==========
<form action="first.jsp" >
Name:<input type="text" name="userName"/><br/>
<input type="submit" value="submit"/>
</form>
first.jsp
=========
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String n=request.getParameter("userName");
out.print("Welcome "+n);
out.println("<br /><br />");
//creating form that have invisible textfield
out.print("<form action='second.jsp'>");
out.print("<input type='hidden' name='uname' value='"+n+"'>");
out.print("<input type='submit' value='Submit'>");
out.print("</form>");
out.close();
%>
</body>
</html>
second.jsp
===========
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
//Getting the value from the hidden field
String n=request.getParameter("uname");
out.print("Hello "+n);
out.close();
%>
</body>
</html>
No comments:
Post a Comment