Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have tried with all these things but giving url like
/get.do. i have two forwaed pages success and failure.if success i want url like ..../projectname/success.jsp. how can i get this one

i have used the following code but none of working.

Java
public class LoginAction extends Action {
   public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
       String status;
       String msg=null;
      String originalURI=(String)request.getAttribute(org.apache.struts.Globals.ORIGINAL_URI_KEY);
      
       System.out.println("originalurl========"+originalURI);
       Loginform lf=(Loginform)form;
       String name=lf.getName();
       String pwd=lf.getPwd();
       if(name.equals("swapna") && pwd.equals("swappna"))
       {
          status="success"; 
       }
       else
       {
           status="Failure";
       }
      //System.out.println("hfjkfhkfhef===="+ mapping.getPath()); 
       String url=request.getAttribute("javax.servlet.forward.request_uri");
       String url1=request.getAttribute("javax.servlet.forward.query_string")
       System.out.println("path========-----"+url);
       return mapping.findForward(status);
   }
}




is there any way to get original url.
Posted

1 solution

Hello,

You can obtain the actual URL by using code similar to one shown below.
Java
ActionForward af = mapping.findForward(status);
System.out.println("path========-----".concat(af.getPath()));

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900