Announcement Announcement Module
Collapse
No announcement yet.
null pointer on redirect Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • null pointer on redirect

    Hi. i'm having problems with this.

    Trying to redirect a view to another...

    publi class PageA implements Controller {


    public ModelAndView handleRequest(HttpServletRequest request,
    HttpServletResponse response) throws Exception {

    Map map1 = new HashMap();
    Map map = new HashMap();
    String mode= StringUtils.defaultifEmtpy( request.getParameter("mode"), "");

    if( mode.equals("something") ){
    return processThis(request, response, map);
    }

    return new ModelAndView("page1", map);
    }


    and then forward i have...


    public ModelAndView processThis(HttpServletRequest request,
    HttpServletResponse response, Map map) throws Exception {

    do.... something..
    map = populateMap( request, map);

    return new ModelAndView("redirect: page2.html", map); //<-- ignore the space.....

    }


    public void Map populateMap( request ) {

    if( request.getParamenter("p1") != null )
    map.put("p1", request.getParameter("p1") );
    if( request.getParamenter("p1") != null )
    map.put("p2", request.getParameter("p2") );
    if( request.getParamenter("p2") != null )
    map.put("p3", request.getParameter("p3") );
    if( request.getParamenter("p3") != null )
    map.put("p4", request.getParameter("p4") );
    .
    .
    .
    .


    return map;
    }

    }

    that gets me

    java.lang.NullPointerException
    at java.net.URLEncoder.encode(URLEncoder.java:188)
    at org.springframework.web.servlet.view.RedirectView. urlEncode(RedirectView.java:237)

    and my controllers are fine... because if i do
    return new ModelAndView("page2", map);


    instead of the redirection, it works fine with no errors... but it doesnt executes the
    instructions in Page2Controller, which is what i need.


    this is how a i deffined my controllers


    <bean id="page1Controller" class="com.mb.action.Page1Controller" autowire="byName" />
    <bean id="page2Controller" class="com.mb.action.Page2Controller" autowire="byName" />


    <bean id="urlMappings" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="page1.html">page1Controller</prop>
    <prop key="page2.html">page2Controller</prop>
    </props>
    </property>

    <property name="interceptors">
    <list>
    <ref bean="localeChangeInterceptor" />
    </list>
    </property>
    </bean>


    any help would be appreciated.

    Im already upset , can not find why is getting me errors......


    Could it be that i am passing to many parameters trough the map to the other controller ???????
    how many parameters are allowed ????

    im passing strings and objects throught the map..
    Last edited by superrick79; Mar 10th, 2010, 01:48 PM.
Working...
X