File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

problem while forwording the JSP page

trupti nigam
Ranch Hand

Joined: Jun 21, 2001
Posts: 614
following is the code for A.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>JSP Example For SCJD</title>
<%! String who="";%>
Enter your name:<input type="text" name="who">
<input type=submit value="Submit">
<jsp:forward page="welcome.jsp">
<jsp aram name="who" value="<%= who%>"/>
and below is the code for welcome.jsp
<title>Trupti's first JSP for SCJD</title>
<%--<%! String name="";%>--%>
Welcome!! <%=who%>.
This is my first example for the SCJD study group.
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?
[ 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: 1873
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,
<form name='f' action='/jsp/Welcome.jsp' method=post>
<input type='text' name='name' value='Trupti'>
<input type='submit' name='submit' value='Submit'>
and Welcome.jsp code is fine.

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.
I agree. Here's the link:
subject: problem while forwording the JSP page
It's not a secret anymore!