aspose file tools*
The moose likes JSP and the fly likes request.getAttribute Not Displaying Anything In JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "request.getAttribute Not Displaying Anything In JSP" Watch "request.getAttribute Not Displaying Anything In JSP" New topic
Author

request.getAttribute Not Displaying Anything In JSP

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi everyone,

I have servlet send a request parameter to a JSP, and i am just extracting the values from the request object in the JSP and displaying it. But the values aren't getting printed at all. I debugged the code and i found the request object is coming to the JSP loaded with the values but its not printing anything. Here is my JSP:

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Well I figured out what the mistake was. Changed the scriptlet tag to expression tag. And its printing the values, except the "percentage" value. Its coming to the jsp into the request object, but somehow its printing null! My updated JSP:


My Servlet:


Could you tell me how come my two values are getting printed and not the third???
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're printing parameters, but setting attributes.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Got it! Thanks Dave!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No problem; glad I could help :)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Scriptlets? In 2010? Is this legacy code? If not, it's high time to update your JSP knowledge.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Its just something i tried out. Actually my main intention was to learn calling an EJB from a servlet and displaying the result in an JSP. I hardly use JSP's. If the JSP specification and all have changed a lot, i would be glad to look into it. Please give me some details...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

JSP 2.0. JSP EL.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Ok. Thanks all! I'll look into it!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I looked at some of documents in Google and found out that JSP 2.0 makes extensive use EL, which comes from JSTL. Now, i have never used JSTL, so would i be able to learn JSP 2.0 without knowing JSTL 1.0? Or should i go through JSTL as well before digging into JSP 2.0?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Somnath Mallick wrote:... EL, which comes from JSTL.

That is not correct. As of JSP 2.0, the EL is evaluated by the core JSP engine and is independent of the JSTL.

Now, i have never used JSTL, so would i be able to learn JSP 2.0 without knowing JSTL 1.0?

JSTL 1.0 is for JSP 1.2. If you are using JSP 2.x, you should be using JSTL 1.1 or 1.2.

And without the JSTL, you'll need to resort to using scriptlets in your pages to do pretty much anything. Bad idea. Very bad idea. Man up and learn JSTL and step into the modern world of JSP.

Or should i go through JSTL as well before digging into JSP 2.0?

Learn the JSP 2.0 EL and JSTL in conjunction with each other. They go together like hand and glove.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Ok. Thanks!! I will start with JSTL 1.2 then!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

The JSTL Specification is easy to read. I'd suggest using it for your research.

The EL Specification is a little tricky. It's polluted with stuff for JSF that doesn't apply to JSP, so you have to be careful not to get confused.

Be sure that any material you use does not focus on JSP scriptlets. They're outdated and replaced by the JSTL and EL.
 
wood burning stoves
 
subject: request.getAttribute Not Displaying Anything In JSP