Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-3862

help,request.getServletPath() still return null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.3.1
    • 2.3.12
    • Dispatch Filter
    • None
    • websphere 7.0.12,struts2.3.1.1,jdk1.5

    Description

      I tried the URL you provided like this,【http://struts.apache.org/2.x/docs/websphere.html】。

      I don’t want a temporary fix,so I try the solution of servlet LaunchServlet as you provided like this:
      1) add a servlet that initializes the Struts Dispatcher with the servlet context:
      import org.apache.struts2.dispatcher.Dispatcher;

      public class LaunchServlet extends HttpServlet implements Servlet {

      public LaunchServlet()

      { super(); }

      public void init(ServletConfig arg0) throws ServletException

      { // this works around a bug in the websphere classloader. super.init(arg0); Dispatcher d = new Dispatcher(getServletContext(), new HashMap<String, String>()); }

      }
      2) launch it at start-up (web.xml):
      <servlet>
      <servlet-name>dummyaction</servlet-name>
      <servlet-class>com.xxx.yyyyyy.service.LaunchServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
      </servlet>
      3) Run application and everything should work.

      But it not works ,the method request.getServletPath() still return null

      I use struts2.3.1,and websphere 7.0.12

      Follws is before my issue: https://issues.apache.org/jira/browse/WW-3859
      I use as follows
      I create a class:
      public abstract class BaseAction extends ActionSupport implements
      ServletRequestAware, ServletResponseAware, ServletContextAware {
      protected HttpServletRequest request;
      protected HttpServletResponse response;
      protected HttpSession session;
      .........
      public String getServletPath()

      { return request.getServletPath(); }

      ..........
      // get / set method
      public void setServletRequest(HttpServletRequest request) {
      this.request = request;
      }

      public void setServletResponse(HttpServletResponse response) {
      this.response = response;
      }

      public void setServletContext(ServletContext context) {
      this.context = context;
      }
      }
      now ,in tomcat 5.5 run environment,getServletPath() method can return correct value,but in websphere 7,it return null.first,i distrust it is some problem in webphere.so i create a simple jsp file and write above code in new jsp file,very magical,it return correct value.i arrive the net to look for the answer.but,nothing i find.it's struts bug?Looking forward to reply.

      Attachments

        Activity

          People

            lukaszlenart Lukasz Lenart
            houwj hou wj
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified