File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSTL returns null but script tags dont Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSTL returns null but script tags dont" Watch "JSTL returns null but script tags dont" New topic
Author

JSTL returns null but script tags dont

Mohammed Uddin
Ranch Hand

Joined: Mar 04, 2012
Posts: 31
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
Bartender

Joined: Oct 14, 2005
Posts: 18988
    
    8

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

Joined: Mar 04, 2012
Posts: 31
Yes that's correct.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18988
    
    8

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

Joined: Mar 04, 2012
Posts: 31
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
Bartender

Joined: Oct 14, 2005
Posts: 18988
    
    8

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

Joined: Mar 04, 2012
Posts: 31
Hi,

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

MoSha.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSTL returns null but script tags dont