• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2 Action Not forwarding to a result

 
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have my action configured in struts-xml, evidently my action completes succesfully because when I refresh the view I can see the result I expect. However the problem is that my action remains on a blank page after completing. What could be the problem?

Im on struts 2.2.1. Here is my action execute and mapping


public String execute(){
try{
member = new MemberService().saveMember(member);
return SUCCESS;
}catch(Exception e){
return ERROR;
}
}



struts.xml


<action name="addMember" class="action.AddMember"
method="execute">
<result name="success" type="dispatcher">/viewmembers.jsp</result>
<result name="error">/error.jsp</result>
<result name="input">/addMember.jsp</result>
</action>


What am i doing wrong? It should at least forward to the error page if there was an error. And like I said when i manually open the viewmembers.jsp I can see that my hibernate code worked perfectly. Help.


 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I'm using tomcat 7, the logs don't show anything unusual. I don't know if I'm missing a required jar but I thought forwards must be part of struts2-core.jar ..I have noticed that non of the forwards actually work anymore. For example if I deliberately make the database unavailable to simulate a hibernate exception I still get stuck in a blank action page instead of getting forwarded to the error page.
 
Tom Rispoli
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have the xwork jar file in your class path? I think xwork might handle the forwarding stuff.
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Rispoli wrote:Do you have the xwork jar file in your class path? I think xwork might handle the forwarding stuff.



Yes I have xwork-core2.2.1.1.jar in my WEB-INF/lib folder
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I added some prinln statements and I can see their output on tomcat console...but I still aint getting forwarded to this page. I don't think JSP is the problem because if i request the page by itself it gets rendered completely with the hibernate results showing that the action was successful.
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Samson Mlati wrote:

Tom Rispoli wrote:You may be getting some kind of failure in your jsp. Did you check the log file for your app server? Maybe putting some println statements early in the JSP would help identify if the JSP is being run.



I added some prinln statements and I can see their output on tomcat console...but I still aint getting forwarded to this page. I don't think JSP is the problem because if i request the page by itself it gets rendered completely with the hibernate results showing that the action was successful.




After almost giving up I figured out my mistake. I was forwarding to a JSP page that is a result to another action, I fixed it by configuring my action result to type redirectAction that forwards to the appropriate action. Works like a charm!!
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic