0

I would like to capture the .html url in my actionServlet. Currently .do url I am capturing in actionSrvlet.

Web.xml -- ActionServlet `

<servlet-name>ControllerServlet</servlet-name>
        <servlet-class>com.mm.wp.webapp.common.WPActionServlet</servlet-class>
            <init-param>
                <param-name>labelresource</param-name>
                <param-value>LabelResources</param-value>

            </init-param>
            <init-param>
            <param-name>errorresource</param-name>
            <param-value>ErrorResources</param-value>
            </init-param>
            <init-param>
            <param-name>tootipresource</param-name>
            <param-value>TooltipResources</param-value>
            </init-param>
        <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
         <url-pattern>*.do</url-pattern> 
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>ControllerServlet</servlet-name>
         <url-pattern>*.html</url-pattern> 
    </servlet-mapping>`

Could you please suggest me what i have to do more to capture .html url in my ActionServlet ?

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Prafulla
  • 41
  • 4
  • So your .html maps to your servlet and then what? How will the html be served? – ramp Feb 28 '17 at 07:13
  • @ramp , that what i am not getting i am assuming as .do url capturing in action servlet same like that .html will work , but it does't. – Prafulla Feb 28 '17 at 08:55

1 Answers1

0

that what i am not getting i am assuming as .do url capturing in action servlet same like that .html will work , but it does't.

Well, the Struts 1 flow would have the Controller Servlet expecting an Action Mapping (for that url minus the extension), an Action class and invoke the execute() method.

What would you do for your html path? You need to write a common custom Action class that reads the input request path and forwards to that html.

Something like (untested)

//Refer http://stackoverflow.com/questions/4278083/how-to-get-request-uri-without-context-path to get the url path

public class HtmlAction extends Action{
   public ActionMapping execute(.....){
        String reqHtml = //see above;
        request.getServletContext().getRequestDispatcher(reqHtml).forward(request, response);
        return null;
   }
}
ramp
  • 1,256
  • 8
  • 14
  • Hi Ramp, there are two types of urls are available at my application 1) https://dev.online.mm.com/mw/wpclient/mpHelp/searchresults.html 2) https://dev.online.mm.com/mw/wp-client/displayNewProjectScreen.do In ActionServlet i am able to get the referer of .do url from the header and now i want to get the referer of .html url. but when the url is of .html then actionServlet is not get called. – Prafulla Feb 28 '17 at 11:18
  • @Buhake Sindi : would you please help me for this. – Prafulla Mar 01 '17 at 13:10