• Post Reply Bookmark Topic Watch Topic
  • New Topic

Suppressing mapping.forward()  RSS feed

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am facing a rather unusual situation, the solution to which I'm oviously unable to figure out and hence this post.
It's something like, I have this JSP page on whose submission, a previously invisible text msg present within <DIV> tags is to be made available while an Action class is invoked to process the information entered by the user on this page.
Hereof, the requirement is that incase the Action class encounters an exception, the control is to be sent to an error page. However, if no error is encountered then the control doesn't need to be sent to any other JSP. But well, this seems to be an unacceptable scenario as per the Struts framework. Every Action class has to return a forwarding path!

For now, i send the control back to the invoking JSP page. But it looks kind of weird when after a while the JSP page suddenly reloads on it's own.

Is there any way to circumvent this shortcoming? To suppress the mapping.forward() in a way that the control need not necessarily have to be routed back to a JSP? I tried setting the forward path as "null", but as expected it threw an exception :roll:

Any help would be much appreciated
 
Ranch Hand
Posts: 96
Scala Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We do what you are currently doing (forward to same jsp) all the time. What in the framework makes you think this is unacceptable?
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might hit yourself when you learn how easy this is...you just need to return null from your execute method. If you take a look at the javadocs they say "Returns: The forward to which control should be transferred, or null if the response has been completed". I return null in cases where the action causes a file to be downloaded.

- Brent
 
Anirvan Majumdar
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


We do what you are currently doing (forward to same jsp) all the time. What in the framework makes you think this is unacceptable?



Guess you didn't get what i was trying to get across. Even i know Struts allows forwarding to the same JSP! All i was saying that when the page reloads after sometime (i.e, when the Action class returns the forward path to the same JSP), one can clearly make out the page reloading. And it is the client's requirement that nothing of that sorts should happen!

@Brent : I tried that one, but the application crashed
[ February 15, 2006: Message edited by: Anirvan Majumdar ]
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm...I guess every time I return null from my execute method, I have already sent something back on the response. I would research topics related to servlets and see if there is something you need to set on the HttpServletResponse. Otherwise I would think about displaying a "Processing your request" message when the user submits and then displaying a page with a "Done processing" message after your action finishes.

- Brent
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!