• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Struts handle first request.

 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have simple question about how struts handle jsp page for the first time.

Lets say i have jsp page called index.jsp which has a form with some elements.

I know whenever this form is submitted ActionServlet receives the request and then delegates it to the RequestProcessor which call series of method to get the action path and create mapping,form and action etc.

But how the index.jsp itself is handled for the first time.

I.e lets say if i have entered the url http://localhost:80/index.jsp for the first time.

Then RequestProcessor class gets the path,but,the path is not an action it is just jsp page to display(no mapping found in struts config.xml) so probably most of the process method return null right?

SO how struts handle this request and display the jsp page.

Your help is appreciated.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts doesn't handle requests for JSP pages by default--the container does. Typically, Struts 1 handles requests mapped to the "*.action" pattern, which isn't "*.jsp".
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this true,even if i set the URL patttern for jsp to be handled by ActionServlet in web.xml?

Also what about after execute method returns,lets say it has to forward the request to jsp,so even in this case is it the container that handles the request?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Siva Masilamani wrote:is this true,even if i set the URL patttern for jsp to be handled by ActionServlet in web.xml?


Of course not; if you change it, it'll be whatever you changed it to.

Also what about after execute method returns,lets say it has to forward the request to jsp,so even in this case is it the container that handles the request?


Not sure what you're asking--here you're saying you're accessing a JSP *via* an action, as opposed to accessing the JSP directly.

Ideally, a Struts application will never access a JSP directly.
 
Siva Masilamani
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me put it clearly

ActionServlet is configured in web.xml in such a way that it has to handle request coming in with either .do or .jsp

here is my action mapping


Let's say,the execute method returns the forward name as success,so the request should be forwarded to the jsp page.

Since i have configured that it should be handled by ActionServlet,how struts handles this request ?
If it calls RequestProcessor method it definitely won't find any Action mapping for the path associated with the request as the path ends with .jsp
?.

So in that case how struts handles the request?is there any condition like if the path is for .jsp it should be handled by container?

Also if index.jsp is my home page and when i type the URL as http:/localhost:80/webapp/index.jsp.

Since i have configured that this request should be handled by ActionServlet,how this request is handled?

Hope i have clearly explained my question.
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!