File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem while forwording the JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem while forwording the JSP page" Watch "problem while forwording the JSP page" New topic
Author

problem while forwording the JSP page

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 613
following is the code for A.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>JSP Example For SCJD</title>
</head>
<body>
<%! String who="";%>
<form>
Enter your name:<input type="text" name="who">
<input type=submit value="Submit">
</form>
<jsp:forward page="welcome.jsp">
<jsp aram name="who" value="<%= who%>"/>
</jsp:forward>
</body>
</html>
and below is the code for welcome.jsp
<html>
<head>
<title>Trupti's first JSP for SCJD</title>
</head>
<body>
<%--<%! String name="";%>--%>
Welcome!! <%=who%>.
This is my first example for the SCJD study group.
</body>
</html>
when I submit the name, the welcome.jsp should display the line with the name entered by the user.
e.g. welcome!! trupti
But the A.jsp directly forwords the request to welcome.jsp without showing the form.
How do I achieve it?
thanks,
Trupti
[ November 27, 2002: Message edited by: trupti nigam ]
[ November 27, 2002: Message edited by: trupti nigam ]
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Trupti,
i guess what u want is,
simple HTML that has a form having Name field and Submit button and then the action for that form to be "welcome.jsp".
when u click on Submit after entering the Name it should go to Welcome page that says "Welcome, <<user>>", right?
if i were u , i would have done following,
<html>
<form name='f' action='/jsp/Welcome.jsp' method=post>
<input type='text' name='name' value='Trupti'>
<input type='submit' name='submit' value='Submit'>
</form>
</html>
and Welcome.jsp code is fine.
regards,
Maulin
franci
Greenhorn

Joined: Aug 30, 2002
Posts: 3
the jsp:forward tag takes to the specified page without any delay, so the code will not work. The solution given by maulin is perfectly ok. it will work
Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Trupti,
There is small change in welcome.jsp.You are passing the parameter to welcome.jsp thru jsp param but in welcome.jsp you should get the same param by using the getParameter("<parameter name>") into the string and then print it in the scriptlet.Hope it helps you.
Ravi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem while forwording the JSP page