• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem while forwording the JSP page

 
Ranch Hand
Posts: 647
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Hey, check out my mega multi devastator cannon. It's wicked. It makes this tiny ad look weak:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic