title: Liferay : How to Redirect to Public page using RequestDispatcher in Liferay
body: <p>I have defined a Page consisting of my six Portlets and configured that inside the <code>portal-ext.properties</code> file as my default Lnding page .</p>
  
  <p>I have  a Custom Login Page for contacting to my Database , and once the user is Valid i am redirecting him to this page using  /user/test/home and also tried using <code>http://localhost:8086/user/test/home</code></p>
  
  <p>But this did not worked , i kept on getting</p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>public void doView(RenderRequest request, RenderResponse response)
              throws PortletException, IOException {
  
          response.setContentType("text/html");
  
          System.out.println("Inside the doView Method");
          PortletRequestDispatcher dispatcher = null;
          if (this.name.isEmpty()) {
              dispatcher = getPortletContext().getRequestDispatcher(
                      "/WEB-INF/jsp/AllInOne_view.jsp");
          } else {
              request.setAttribute("name", this.name);
              dispatcher = getPortletContext().getRequestDispatcher(
                      "http://localhost:8086/user/test/home");
          }
          this.name = "";
          this.action = "";
          dispatcher.include(request, response);
      }
  
  
  17:53:47,765 ERROR [render_portlet_jsp:154] java.lang.NullPointerException
      at org.ravi.learning.AllInOne.doView(AllInOne.java:57)
      at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
      at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
      at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
      at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
      at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:93)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
  </code></pre>
  
  <p>The AllinOne.java is my Custom GenericPortlet class AllInOne.java:57 is </p>
  
  <pre class="lang-java prettyprint-override"><code>    dispatcher.include(request, response);
  </code></pre>
  
  <p><strong>Updated Part Here</strong> </p>
  
  <p>This is the java Class </p>
  
  <pre class="lang-java prettyprint-override"><code>package org.ravi.learning;
  
  import java.io.IOException;
  
  import javax.portlet.ActionRequest;
  import javax.portlet.ActionResponse;
  import javax.portlet.GenericPortlet;
  import javax.portlet.PortletException;
  import javax.portlet.PortletRequestDispatcher;
  import javax.portlet.RenderRequest;
  import javax.portlet.RenderResponse;
  
  public class AllInOne extends GenericPortlet {
      String action = "";
      String name = "";
  
      public void processAction(ActionRequest request, ActionResponse response)
              throws PortletException, IOException {
  
          System.out.println("Inside the Process Action Method new");
  
          this.action = request.getParameter("myAction");
  
          if (this.action.equals("formAction")) {
              this.name = request.getParameter("personName");
  
          }
          String urlpaths = "http://localhost:8086/user/test/home";
          response.sendRedirect(urlpaths);
  
      }
  
      public void doView(RenderRequest request, RenderResponse response)
              throws PortletException, IOException {
  
          response.setContentType("text/html");
  
  
      }
  
  }
  </code></pre>
  
  <p>As a new user i cant post images , so please refer this external link for the image</p>
  
  <p><a href="http://tinypic.com/view.php?pic=a43nlv&amp;s=5" rel="nofollow">http://tinypic.com/view.php?pic=a43nlv&amp;s=5</a></p>