aspose file tools*
The moose likes JSP and the fly likes Attributes sent from JSP wont show in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Attributes sent from JSP wont show in Servlet" Watch "Attributes sent from JSP wont show in Servlet" New topic
Author

Attributes sent from JSP wont show in Servlet

Tontang Bei
Ranch Hand

Joined: Oct 21, 2006
Posts: 130

In my servlet:

I get output Null for both Attributes that I set. What am I doing wrong? Ive even tried using hidden form fields in the JSP to send. But still the result is Null in my servlet for some reason. I can see their outputted values in the JSP for sure when I use <%=%> . Any help is welcome
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Have you forwarded the request from jsp to servlet ?


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
When you set a request attribute in the JSP it is for that request. Request generally terminates at the JSP hence when you don't explixitly forward the request the request.setAttribute would only be available to that JSP page only and any included page.

The hidden form fields should work.
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
Hi,

I don't understand your JSP: who sets the request attributes 'message', 'paramName' and 'jobs'? Were you trying to use 'request.getParameter(String)'?


SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Tontang,

you can use hidden input fields (inside a form),

to retrieve them in your servlet use the getParameter(..) method.
(instead of getAttribute(..))

Herman
Manzar Zaidi
Ranch Hand

Joined: Oct 21, 2004
Posts: 43
I dont see any problems with the code, it is doing what you rote it for,
When you write
If the attribute paramName is not set, it returns null.

Then if you set that back as a request attribute you get null on subsequent calls.


So that
Will return null.


SCJP 1.2, SCWCD 1.4.<br />What goes around comes around ... with ver 1.1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Attributes sent from JSP wont show in Servlet