struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hou wj (JIRA)" <j...@apache.org>
Subject [jira] [Created] (WW-3862) help,request.getServletPath() still return null
Date Tue, 07 Aug 2012 03:09:02 GMT
hou wj created WW-3862:
--------------------------

             Summary: help,request.getServletPath() still return null
                 Key: WW-3862
                 URL: https://issues.apache.org/jira/browse/WW-3862
             Project: Struts 2
          Issue Type: Improvement
          Components: Dispatch Filter
    Affects Versions: 2.3.1
         Environment: websphere 7.0.12,struts2.3.1.1,jdk1.5
            Reporter: hou wj


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.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

Mime
View raw message