• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL returns null but script tags dont

 
Mohammed Uddin
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have been using script tags on my JSP page and it returns values as expected. But when I try to do the same thing it returns null. Can someone please help.

Login Page [JSP]:


LoginServlet:


Business Logic Class - AccountHolder:


Login success Page [JSP]:


For my login page, on line 12 - if I use:

then it returns the correct value on line 14 for the login success page but I would like to know why the JSTL tag returns a null when used.

Thanks,
MoSha
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any JSTL tags anywhere in your post.

But apparently you expect



to identify an AccountHolder object which is in request scope with a name of "loginAccount". Do I understand that correctly?
 
Mohammed Uddin
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that's correct.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't you expect that you would have to specify "loginAccount" somewhere in that line of code, if you wanted to get that object from the request scope?

But anyway the way to do it using JSTL and EL is like this:


 
Mohammed Uddin
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

Thanks alot for your help. It did the trick but I would like to know how one would or could specify "loginAccount" on the JSP:useBean tag?

I do now understand that making the new object would indeed set the property values to null (because it is a new object) but how would one using the jsp use bean tag to make the new object equal to the same type of object in, say, the request session?

Thanks,
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohammed Uddin wrote:Thanks alot for your help. It did the trick but I would like to know how one would or could specify "loginAccount" on the JSP:useBean tag?


Sorry, I really don't know. I have switched over to JSTL and EL completely and I don't use those old tags any more. My guess would be id="loginAccount" rather than id="acc" but as I said, scriptlets are ancient history to me.
 
Mohammed Uddin
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you very much. It did the trick very nicely.

MoSha.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic