Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts execute called when jsp loads

 
Matt Sloan
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how do you forward to an action?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try what is called a setup action.
Instead of going to the jsp, go to the action that (upon completion) forwards to the jsp.
 
Matt Sloan
Greenhorn
Posts: 26
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic