Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts using ServletConfigInterceptor for accessing the HttpServletRequest.

 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First of all hi to all Ranchers ,



Is implementing the ServletRequestAware is not sufficient for accessing the ServleRequest .

why do we need a ServletConfigInterceptor interceptor to associate with the action ??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The interceptor is what calls setServletRequest() to actually set the servlet request.

Note that directly accessing the servlet request ties your class to the servlet spec and makes it less testable--in general you rarely need to do this.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David ,

After refering to the some sites i saw that implementing Aware interfaces in for access resources is a bad approach , and the best would be use the Spring Framework IOC for getting all these things to be done .

Is this would be the right approach ??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would depend on what resources you're trying to access.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Generally these resources like Request ,Response , Context , and Config are sufficient know to work (Correct me please if i am wrong).

And also i want to use Hibernate as ORM , so i will mention all these like in a ApplicationContext XML file.

Will this be a correct approach ??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again: it should be rare that you need to access the request (or response) directly in S2.

"Context" means nothing by itself; I don't know what context you're talking about. Same with "Config".

If you have Spring questions, ask them in the Spring forum.
 
RaviNada Kiran
Ranch Hand
Posts: 528
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Again: it should be rare that you need to access the request (or response) directly in S2."


This is waht i am looking for.
Thanks once again.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, but that doesn't really have anything to do with Spring or the original question regarding the interceptor.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic