| Author |
struts execute called when jsp loads
|
Matt Sloan
Greenhorn
Joined: Aug 27, 2004
Posts: 26
|
|
Is there a way to have the action class' execute() called when my jsp first loads? I think I have seen this done before, but I can't find it now. Thanks
|
 |
Clifford Adams
Ranch Hand
Joined: May 12, 2004
Posts: 50
|
|
You could forward directly to an action. ie. index.jsp does nothing but forward to /getStuff.do which then does it's thing and forwards to showStuff.jsp [ September 07, 2004: Message edited by: Clifford Adams ]
|
 |
Matt Sloan
Greenhorn
Joined: Aug 27, 2004
Posts: 26
|
|
|
how do you forward to an action?
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Try what is called a setup action. Instead of going to the jsp, go to the action that (upon completion) forwards to the jsp.
|
A good workman is known by his tools.
|
 |
Matt Sloan
Greenhorn
Joined: Aug 27, 2004
Posts: 26
|
|
Thanks for the advice Marc. I finally figured out what a setup Action is and how to create one. So far it is working good, except that the jsp is not loaded. I have done a System.out.println of the mapping.findForward - that is coming back fine, but the web browser doesn't appear to even attempt to load the jsp. The address stays at ../action.do - Any ideas?
|
 |
Marc Peabody
pie sneak
Sheriff
Joined: Feb 05, 2003
Posts: 4725
|
|
Well, the user's browser is only going to display the url that it initially requested. If the request gets bounced around on the server side it does not automatically update the browser's address bar. If what you are getting is a blank screen that means that the mapping.findForward you are using does not match anything set up in your struts-config.xml For instance, if you're doing: return mapping.findForward("success"); you must have this in your mapping: <forward name="success" path="hallo.jsp"></forward>
|
 |
 |
|
|
subject: struts execute called when jsp loads
|
|
|