• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

request.getAttribute Not Displaying Anything In JSP

 
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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???
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're printing parameters, but setting attributes.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it! Thanks Dave!
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem; glad I could help :)
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scriptlets? In 2010? Is this legacy code? If not, it's high time to update your JSP knowledge.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP 2.0. JSP EL.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Thanks all! I'll look into it!
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 483
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok. Thanks!! I will start with JSTL 1.2 then!
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
It's fun to be me, and still legal in 9 states! Wanna see my tiny ad?
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic