GeeCON Prague 2014*
The moose likes Struts and the fly likes understanding Struts 1 with JSPs: How is the control flow when directly requesting a JSP? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "understanding Struts 1 with JSPs: How is the control flow when directly requesting a JSP?" Watch "understanding Struts 1 with JSPs: How is the control flow when directly requesting a JSP?" New topic
Author

understanding Struts 1 with JSPs: How is the control flow when directly requesting a JSP?

Ulrich Doe
Greenhorn

Joined: Dec 09, 2010
Posts: 7
Hi,

I am quite new to J2EE and need to understand and debug an application based on Struts 1. It is running on JBoss. Can anybody point me in the right direction for this question:

When a JSP is directly accessed in the browser, how is the control flow; where is the entry point? I know that Struts is a front controller and there is an ActionServlet.

When setting a breakpoint (Eclipse) in the init() method of the servlet (it is derived from ActionServlet) and launching the debugger, it does not stop there. I don't understand why. Also I have a breakpoint in a custom tag which is called in the JSP. The debugger DOES stop there.

So, my question is: When directly accessing a JSP, why isn't the request routed through the ActionServlet? Is there another central entry point for ALL requests, not only to actions but to the JSPs directly?
Jesus Mireles
Ranch Hand

Joined: Mar 10, 2010
Posts: 122

The request wont be routed to the ActionServlet if you dont have a rule that says to direct it to the action servlet. If you access the JSP directly its going to try to render that JSP which means that it will also evaluate all your tags in the JSP. Its the same thing if you access an html file, any images etc ... it wont go through any ActionServlet. You need to check your web.xml to see what your servlet mappings are.

In order to go through the action you need to find which action to use that is configured with your ActionServlet via the struts-config.xml file. Access that action and your ActionServlet should execute and if the jsp your accessing is the success jsp configured then it will render that jsp.
 
GeeCON Prague 2014
 
subject: understanding Struts 1 with JSPs: How is the control flow when directly requesting a JSP?