Results 1 to 1 of 1
  1. #1
    esolve is offline Member
    Join Date
    Mar 2015
    Rep Power

    Default scope of HttpServletRequest and struts.xml redirect

    I'm looking into a SSH project
    there is an `acting.jsp` file with following code block

    Java Code:
            <s:if test="#request.commonList!=null">
            <s:iterator value="%{#request.commonList}" var="common">
            <td> <s:property value="%{#common.stationRun}"/>  </td>
            <td> <s:property value="%{#common.devRun}"/>      </td>
            <td> <s:property value="%{#common.createDate}"/>  </td>

    the request object carries `commonList` attributes. Setting of `commonList` attributes is done in java source codes:
    Java Code:
            public class BaseAction extends ActionSupport implements
                ServletRequestAware,ServletResponseAware {
                protected HttpServletRequest request = null;
                protected HttpServletResponse response = null;
                public void setServletRequest(HttpServletRequest request) {
                    this.request = request;
                public void setServletResponse(HttpServletResponse response) {
                    this.response = response;
    Java Code:
            public elecCommonMsgAction_extends BaseAction{
                public String home(){
                    List<ElecCommonMsgForm> list = elecCommonMsgService.findElecCommonMsgList();
                    request.setAttribute("commonList", list);
                    return "home";
    acting.jsp is redirected through struts.xml configuration

    Java Code:
            <action name="elecCommonMsgAction_*" class="cn.itcast.elec.web.action.ElecCommonMsgAction" method="{1}">
        	  <result name="home">
        	  <result name="save" type="redirectAction">
        	    <param name="actionName">elecCommonMsgAction_home</param>
        	    <param name="namespace">/system</param>
    In one word, JAVA source codes use the `request` object to inject `commonList` into acting.jsp

    I know there are two ways for going to another page: forward and redirect.
    Java Practices -> Forward versus redirect

    if it is forward, then the requests and request scopes are the same, otherwise, if it is redirec, then the requests and request scopes are different.

    here, in struts.xml configuration, I think it is redirection, so the request scopes are diffrerent, then how can the request.commonList correspond to the equivalent in the java source codes?
    Last edited by esolve; 12-01-2015 at 07:30 PM.

Similar Threads

  1. Replies: 1
    Last Post: 11-18-2015, 01:09 PM
  2. HttpServletRequest: which the parameters?
    By Coringa in forum New To Java
    Replies: 1
    Last Post: 08-09-2014, 09:18 AM
  3. Replies: 0
    Last Post: 04-01-2012, 04:05 PM
  4. HttpServletRequest cannot be resolved-- Help me
    By hphuoc in forum Java Servlet
    Replies: 1
    Last Post: 04-26-2011, 10:23 AM
  5. HttpServletRequest request size
    By Ed in forum Java Servlet
    Replies: 2
    Last Post: 07-02-2007, 03:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts