wood burning stoves 2.0*
The moose likes JSP and the fly likes JSLT EL display session attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSLT EL display session attribute" Watch "JSLT EL display session attribute" New topic
Author

JSLT EL display session attribute

vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
Hi all,
I have a list of names in session. I want to diplay them on jsp using JSTL EL.
in servlet i place the list in session.
and in jsp i did the following

I am getting an error message like this
java.lang.IllegalStateException: jsp.error.page.noSession
Any ideas what is wrong with the code.
How to access the session attribute using JSTLEL
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Not sure why you are getting that particular message, but your code should be:



[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
mine is working if i use scriptlet to get attribute value from session like this

and i am accessing this messages variable in forEach. it is working fine now. but i am not sure why i get that illegastateexception message when i try to use sessionScope!
Is there a way to replace the above scriptlet with EL
[ June 08, 2007: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

You should not need the scriplet. Does my version work for you? Do you get the exception on any reference to a session-scoped variable?
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
yes i tried placing ${not empty but i am getting the error message
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

That error means:

jsp.error.page.noSession=Cannot access session scope in page that does not participate
in any session

For some reason, your page has no session. You need to figure out why. What declarations do you make for the page?
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
the jsp actually consists of two frames. each frame is a result of new request. is this the reason? but session should be available to jsps even if it is new request. right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

Yes, are you sure that you are not using a declaration to remove one of the JSPs from the session?
vijaya bacina
Ranch Hand

Joined: Aug 23, 2005
Posts: 155
The jsp is still in session. otherwise even this statement should not work.
Grace Phone
Greenhorn

Joined: Sep 29, 2011
Posts: 9
I agree with this because I faced similar problem because there was session=false directive declared in common page used by my page. It gave me headache over hours. Then I awared of the stack trace telling me no session in this page. When I enable it session=true and everything works well.

It might work well if you use like this. But when using sessionScope, it gonna give you session not found error.

Thanks to this link http://stackoverflow.com/questions/4730790/problem-with-session-attributes-in-jsp-el-using-spring-mvc

Cheers !

Bear Bibeault wrote:That error means:

jsp.error.page.noSession=Cannot access session scope in page that does not participate
in any session

For some reason, your page has no session. You need to figure out why. What declarations do you make for the page?


Regards,
Grace
aatish pandya
Greenhorn

Joined: Apr 20, 2011
Posts: 21
Hi Vijaya,

I am having a similar problem,

I am trying to display a sample List using EL from Servlets and Bean File, but the output is blank Browser!

Bean File -



Servlet


JSP File



Muhammad Rizwan
Greenhorn

Joined: Feb 28, 2012
Posts: 1
Hi Aatish

I am having same problem , the output is blank Browser!.

how did you manage to get around this?

thanks
Muhammad



 
 
subject: JSLT EL display session attribute
 
Similar Threads
ComboBox in jsp
Use a variable instead of "admin" in <% if (request.isUserInRole("admin")) { %>
Doubt in EL's sequence
Couple of questions on JSP
how to use EL