Evan Chua-Yap wrote:
> hi all! i just downloaded the early JSP Tutorial chapters. In the
> chapterfor handling forms, the hellouser example uses an include
> directiveto show the submitted name. i was wondering: is it
> possible to specify a 'submit' action that goesto a different .jsp
> page, and show the submitted name on that page?? here's what i have
> right now, but i get a Cannot Compile error for show.jspis there a way
> to get it to work?(Note: adding <jsp:useBean id="myNameHandler"
> scope="session" class="myForm.NameHandler"/>right before i do the
> getProperty doesnt help) getName.jsp--------------------<html>
>
> <body>
>
> <jsp:useBean id="myNameHandler" scope="session"
> class="myForm.NameHandler"/>
<jsp:useBean id="myNameHandler" scope="request"
class="myForm.NameHandler"/> is what you really want if you are just
forwarding/including requests.
>
>
> <jsp:setProperty name="myNameHandler" property="*"/>
>
> <form method=get action=showName.jsp>
<form method="get" action="showName.jsp"> is safer.
>
>
> Your Name: <input type="text" name="username" size=25><br>
>
> <input type="submit" value="Submit">
>
> <input type="reset" value="Reset">
>
> </form>
>
> </body>
>
> </html>
>
> showName.jsp
>
> ------------
>
> <html>
>
> <body>
>
> Hello, <jsp:getProperty name="myNameHandler" property="username" />!
>
> </body>
>
> </html>
You must specify a <jsp:useBean> before you use <jsp:getProperty> or
<jsp:setProperty>, (or suffer the compile error you are currently
getting).
So try:
<html>
<body>
<jsp:useBean id="myNameHandler" scope="request"
class="myForm.NameHandler"/>
Hello, <jsp:getProperty name="myNameHandler" property="username"
/>!
</body>
</html>
--
Michael Hu, Paradox Team, Corel Corporation
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html