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

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

 
Ulrich Doe
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
IntelliJ IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic