• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot get fields of session scoped bean

 
Daniel Gurianov
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All.

I have next jsp in place



and next form to feed the data



However, when i switch scope of the cars.domain.User bean created in jsp from request to session or application , i stop to see (they are empty ) User.login and User.password fields, that jsp:setProperty should set.

Any idea what am i missing ?
Thank you.
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jsp:useBean element declares that the page will use a bean that is stored within and is accessible from the specified scope, which can be application, session, request, or page. If no such bean exists, the statement creates the bean and stores it as an attribute of the scope object. The value of the id attribute determines the name of the bean in the scope and the identifier used to reference the bean in EL expressions, other JSP elements, and scripting expressions. The value supplied for the class attribute must be a fully qualified class name. Note that beans cannot be in the unnamed package. Thus the format of the value must be package-name.class-name.

Keeping this in mind, can you check are you properly setting object in HTTPSession or not ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your form action should be to a servlet, not a JSP. The servlet can then redirect or forward to a HSP as appropriate to generate the view.

Performing actions in a JSP is a fundamental error in a web application.
 
Daniel Gurianov
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By putting design mistakes aside, the issue was in line 14 of jsp file, where </jsp:useBean> resides.
It looks, that contents put between <jsp:useBean> and </jsp:useBean> lives in some other context, and all properties that (probably) are set at this moment , are not visible after tag is closed.
After i removed </jsp:useBean> from line 14 and autoclosed , values automagically appeared.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!