java - forward request from servlet to jsp after login using tomcat -


i'm trying forward request jsp file after login using tomacat. (servlet) not forwarding request. can figure out error here ?

servlet :

public class authenticationserver extends httpservlet {      public void dopost (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         doservice(request, response);     }      public void doget (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         doservice (request, response);     }      public void doservice (httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {         string user = request.getremoteuser();         request.setattribute("user", user);         requestdispatcher dispatcher = request.getrequestdispatcher("/" + request.getparameter("direct"));         dispatcher.forward(request, response);     } } 

when printed "/" + request.getparameter("direct"), prints out /welcome.jsp. don't forwards it.

request.getrequestdispatcher(string path); 

the path specified may relative, although cannot extend outside current servlet context. if path begins "/" interpreted relative current context root. if servlet container cannot return requestdispatcher method returns null.try this:requestdispatcher dispatcher = request.getrequestdispatcher(request.getparameter("direct"));


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -