Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Problem with html:form when session invalidated

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am using Struts1.1 with Resin 2.1.12


I am trying to invalidate the session when the visitor is not logged in to prevent sessionid to be attached to the links (for search engine optimization).

The problem is when I have a html:form tag after that it gives me :

[ServletException in:footers/footer.jsp] Can't call getAttribute() when session is no longer valid.'

but I specified the scope in action mapping as "request" not "session", also I tried to add scope attribute to html:form but nothing changed.

So could someone please tell me why he is asking for session object 'getAttribute()'?

thanks in advance
[ September 20, 2004: Message edited by: Alexan Kahkejian ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The footer.jsp is calling getAttribute() on the session object.

Am I wrong? If so, please post your footer.jsp
 
Alexan Kahkejian
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is my footer.jsp


There is no getAttribute() on session object. the problem will solve only by removing the <html:form> tag

P S : the form here is fake I am just using it to figure out the cause of the error which occured in other jsp pages.

Thanks
[ September 20, 2004: Message edited by: Alexan Kahkejian ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try putting this in your struts-config.xml:
<controller locale="false"></controller>

That's the only thing I can think of. That and maybe making sure that the ActionMapping's scope is also request.
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi alexander

I feel the problem with ur code is that u have a form with some action and that might be having some action form assocaited with it and in the config file u might not have given the scope for this action mapping......then that will be in session scope so make it request

and one more thing thats not the way u need to hanlde the session issues ...write some custom tag r else inside that login resent instead of invalidating the session just redirect to some page saying session is invalid and from there just direct to the login page of ur application ..its not a good practice to do like this

r else better u can use checklogontag to handle these issues
 
Alexan Kahkejian
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Marc Peabody:
Try putting this in your struts-config.xml:
<controller locale="false"></controller>

That's the only thing I can think of. That and maybe making sure that the ActionMapping's scope is also request.



Thanks for your suggestion but it didn't worked


Originally posted by sreenath reddy:

Hi alexander

I feel the problem with ur code is that u have a form with some action and that might be having some action form assocaited with it and in the config file u might not have given the scope for this action mapping......then that will be in session scope so make it request

and one more thing thats not the way u need to hanlde the session issues ...write some custom tag r else inside that login resent instead of invalidating the session just redirect to some page saying session is invalid and from there just direct to the login page of ur application ..its not a good practice to do like this

r else better u can use checklogontag to handle these issues



I am using ServletFilter to check login but in this code I am only trying to prevent the attachment of sessionid parameter to the links (when cookies are disabled) to allow search engines to index that pages because most SE's don't index pages that have sessionid parameter in the links.

Thanks
[ September 21, 2004: Message edited by: Alexan Kahkejian ]
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi alex

U hadnt metioned whether u had given scope="request" for the form bean asscoaited with ur form bean in ur struts-config.xml
 
Alexan Kahkejian
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by sreenath reddy:
hi alex

U hadnt metioned whether u had given scope="request" for the form bean asscoaited with ur form bean in ur struts-config.xml



Yes, and that is why I feel confused
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The locale of the request will be stored in session thats why its creating a problem and actually the session will be created from serverside whenever first req is fired from that browser at the same time u r invalidating the session ......and the part of the code after invalidating will create a problem .there should be one more req in between to create one more session object after its inactivated by you

Thats why i advices u to move to a diff page
 
Could you hold this puppy for a sec? I need to adjust this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic