Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with the action tag

Status
Not open for further replies.

pajarokillo

Programmer
May 3, 2004
30
ES
Hi!, i have the following problem, in my struts-config.xml i have the next configuration for a Action:

<action path="/login" type="com.icg.merlin.actions.LoginAction" name="loginForm"
validate="true" input="/login.jsp" scope="request">
......
.....
</action>

i want that when my Action class throw an error, it could called to the page that i set up in the input property of the action tag.

Then, in my Action class i had put the next code when occurr an error:

return (mapping.findForward(mapping.getInput()));

but it return a blank page, what is the problem??

I wait that i could had explained well, my english is not good
 
getInput() only returns context-relative path of the input form, but not the logical name for forward instance for the input page that's require in findForward(). so findForward() return no ActionForward in your case and struts returns a blank page.

try use getInputForward() instead. i.e.

return mapping.getInputForward();
 


Can someone help me plssss,

how to make a http request abstraction using Struts.

some code sample would be helpfull.

Thank u

raj
 
In your struts-config.xml file, add input attribute (path to the login jsp page) to login action mapping:

Code:
<action path="/login" type="com.icg.merlin.actions.LoginAction" name="loginForm"
        validate="true" input="/login.jsp" scope="request"
     [COLOR=red]input="/login.jsp"[/color]>  
   .....
</action>

In your LoginAction class, you would do some like this:

Code:
public LoginAction extends Action {

 public ActionForward execute(
                              ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
               	              HttpServletResponse response)
		throws Exception {
     boolean loginSucess = false;

     // TODO:authenticate user
     // ....
     if (loginSucess) {
     } else {
       // this will forward to input page as defined in 
       // the input attribute in the action mapping
       return mapping.getInputForward();
     }
   
 }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top