• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ModelDriver Interceptor + not getting my object

 
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i have written one action class called ClientAction whch implement ModelDriver and Preparable,

The code of my ClientAction.java is as bellow.



and i have also written on custom interceptor called LoginInterceptor.
in which i am checking for the user object from session.

if the user object is found i continue to invoke requested action.

else redirecting to login page.

now the issue is that when i find the user object from session. and my flow goes to ClientAction i am getting client object as null.

if i remove the interceptor everything works fine.

bellow is the stack trace from Login.jsp to ClientAction.java.




and bellow is my code of LoginInterceptpr



I am not able to understand the reason why i am getting client object as null event though i have implemented ModelDriven and Preparable Interfaces.

Bellow is my struts.xml

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember the other day when I said that if you configure an interceptor for an action you have to configure *all* the interceptors for the action? That's actually still true:

I wrote:The actions you defined each set their own interceptor stack consisting *solely* of the login interceptor; this is almost certainly not what you want. If you define an interceptor stack for an action you must define *all* the interceptors that action requires.

You can avoid defining an interceptor stack for each action by defining a default interceptor stack containing all the interceptors you require.


I wasn't making it up, honest.
 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah right..

Thanks Devid.

bellow is how my struts.xml looks now.

 
Jigar Naik
Ranch Hand
Posts: 763
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more question devid.

the interceptor will prevent user from accessing the page directory for example

if the user enters http://localhost:8080/LoginModule/clientAction.action in the address bar of browser user will be redirected to the login page in case of interceptor does not find user object in session.

but what if user know the exact JSP Page name

like bellow

http://localhost:8080/LoginModule/client.jsp

is there any michenism in struts to prevent user from accessing this page directly or i have to go with custom tag and call it in every jsp page. ?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSP pages should be placed somewhere under WEB-INF to prevent direct access. That's a normal JEE web app thing and not related to Struts.
 
Always! Wait. Never. Shut up. Look at this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic