This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes Some problem with local Forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Some problem with local Forward" Watch "Some problem with local Forward" New topic
Author

Some problem with local Forward

Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Hi All,

I have one action in which I am trying to forward to three different pages depending on three different conditions.

Its working fine for success and failure but it doesnt work with the third codition. I get blank page.


<action path="/testAction" type="com.test.TestAction" parameter="action"
input="/TestInput.jsp" name="TestBean" scope="request">

<forward name="success" path="/success.jsp"/>
<forward name="getQuestion" path="/GetQuestion.jsp" />
<forward name="failure" path="/failure.jsp"/>
</action>


Sandeep
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
A blank page generally means that the action class returned a null ActionForward, which can happen if the findForward method doesn't find anything. My best guess is that the problem is a misspelling in your Action class. Are you 100% sure that the statement is spelled correctly, and that it actually gets executed?


Merrill
Consultant, Sima Solutions
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Hi Merrill,

I rechecked it, it is spelled correctly and getting executed too.
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
I have two modules in this applicaton, is it creating problem. But then it should create for success and failure also. But success and failure is working. getQuestion is not working
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Could you post the relevant portion of your action class? That might provide some insight.
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
public ActionForward process( ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)
throws Exception
{


...
...
...
...
...

if (user.getSecretQuestionId() == null || user.getSecretQuestionId().intValue() <= 0) {
log.debug("Forwarding to getQuestion");
//return new ActionForward("success1");
return mapping.findForward("getQuestion");

//return mapping.findForward("failure");
}

log.debug( "forward to input page" );
return new ActionForward( mapping.getInput() );
)
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
I'm assuming that the debug statement "Forwarding to getQuestion" is getting logged.

Do you have any debug statements in your JSP "GetQuestion.jsp"?

Do you have a try catch in your JSP? Are you eating up exceptions that might be thrown in your JSP?

Do you see any output on your server console? or in the server logs?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The next thing I'd look at would be the GetQuestion.jsp. Are you sure it exists and is coded properly? Try renaming the current one and substituting it with one that has nothing in it but "This is GetQuestion.jsp". If this JSP displays correctly and the other one doesn't, you know it's a problem with the JSP.
Sandeep Awasthi
Ranch Hand

Joined: Oct 23, 2003
Posts: 597
Hi Merrill & Sheldon,

Thank you very much for trying to help me. I did very stupid mistake. I added <forward name="getQuestion" ....... /> to some other action in action mapping than the intended one. But really thanks alot.

Kind Regards

Rajesh
[ March 22, 2007: Message edited by: Rajesh Thakare ]
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
You are welcome. Glad that you found the problem.
 
Consider Paul's rocket mass heater.
 
subject: Some problem with local Forward
 
Similar Threads
My Execute method does not called
How to encode the path attribute in action mapping
/* in Struts Action Mapping
[SOLVED] Something wrong with DynaActionForms
action mapping for pre-login