This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing value from JSP to JSP  RSS feed

 
Anthony Philips
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I'm trying to pass a sum value from one JSP to another. I've created a Double sum and tried to store that value into a session. session.setAttribute("SUM","sum);
In the following page I parsed it and printed the sum, but I'm receiving a null value. Any help would be appreciated.
This is the starting page


This is the ending page
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, look carefully at line 12 of your first example, and line 1 of your second.

Secondly, are you new to JSP? Because you're well on your way down the wrong path. Or is this a legacy page that someone else wrote?
 
Anthony Philips
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I noticed that after a bit and I've been able to pass the value. Also yes I am new to JSP. Could you give me a heads up on the path I'm about to go down?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Putting Java code into a JSP has been obsolete for over 12 years. It is now considered an egregiously poor practice.

You will find Java scriptlets (anything with the <% notation) in legacy pages, and in pages created by people who do not know what they are doing, but modern JSP uses the EL (Expression Language) and JSTL (JSP Standard tag Library).

Make sure that whatever learning material you are using emphasizes the EL and JSTL, and notes that scriptlets are old hat. Otherwsie, you are just learning how to do things badly and will develop habits that are really hard to break out of.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always recommend that newcomers to web apps read these articles:
  • The Secret Life of JSPs
  • The Front Man


  • The former explains what JSP is really all about. The second is more advanced and details how modern Java web applications should be structured.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!