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

How to access object saved in the session

 
Greenhorn
Posts: 16
Mac OS X Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellows,

The problem is how to access, from Registration.jsp page using the EL statements, the data that was entered by the user and saved as a object to the session.
After registration, there is no problem with Confirmation page, the data are displayed, but when the user decide to return to Registration.jsp page to edit data, the text box is empty.
I know how to do that with the hidden fields but my goal is to use sessions.

Lets start with code:
Controller.java

User.java:

Registration.jsp:

Confirm.jsp:


Cheers,
Thomas
 
Ranch Hand
Posts: 94
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
problem with this Servlet is that after clicking Edit it will erase your session attribute "user" and create it again
this attribute inside your confirm page so that it will passed to next request
 
Thomas Byrne
Greenhorn
Posts: 16
Mac OS X Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellows,

Thank you bud, but as I said before, I know how to do that with hidden field but the goal is session. I'm pretty sure this is possible although more complicatet than hidden field.

Cheers,
Thomas
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thomas Byrne wrote:Hi fellows,

Thank you bud, but as I said before, I know how to do that with hidden field but the goal is session. I'm pretty sure this is possible although more complicatet than hidden field.

Cheers,
Thomas


well it is not that complicated at all what you are doing is erasing attribute "user" from session and recreating it every time you access Controller.java
in that case yes all you need to do is this
 
Thomas Byrne
Greenhorn
Posts: 16
Mac OS X Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellows,

Thank you again, I tried but I'm afraid it doesn't work like that.

Yogesh Lonkar wrote:


 
Yogesh Lonkar
Ranch Hand
Posts: 94
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thomas Byrne wrote:Hi fellows,

Thank you again, I tried but I'm afraid it doesn't work like that.

Yogesh Lonkar wrote:





Well i am certain that it should allow you to get firstName attribute back from session. because i have compiled your project personaly on my workspace and it work here. may be clean and build will do
 
Thomas Byrne
Greenhorn
Posts: 16
Mac OS X Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi fellows,

Yogesh Lonkar wrote:Well i am certain that it should allow you to get firstName attribute back from session. because i have compiled your project personaly on my workspace and it work here. may be clean and build will do


My apologies, It works if I remove line 28 from Controller.java.
But there is another hiccup with messages. I added some simple validation to the text box, like:

Registration.jsp:
Controller.java:
Regex.java:
After return to the page from Confirm.jsp, even if text box has been filled with correct value, there is always active error message (<span class="error">${message.errorFirstName}</span>).
Any suggestion how to get rid off from that?

Cheers,
Thomas
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thomas Byrne wrote:
Controller.java:

After return to the page from Confirm.jsp, even if text box has been filled with correct value, there is always active error message (<span class="error">${message.errorFirstName}</span>).
Any suggestion how to get rid off from that?

Cheers,
Thomas



Well, you can reset the message Map when you return from Confirm.jsp... And then redirect it to Registration.jsp...
And you can see the place where you are returning from Confirm.jsp to Controller..
 
Yogesh Lonkar
Ranch Hand
Posts: 94
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you must have done as per Rohit Jain said but if you didn't here is some thing i came up with
reply
    Bookmark Topic Watch Topic
  • New Topic