java - Resource not found error while trying to deliver a jsp page -


i working resteasy war file deployed on jboss (6.0.2 eap)

i have following workflow :

  1. url hit calls servlet(doget() method)
  2. this servlet supposed deliver jsp page client

    jsp page resides in webcontent/customfolder

    i use requestdispatcher().forward() method invoke jsp

    the path given in forward("/customfolder/name_of_jsp")

  3. the jsp has form, action attribute points servlet

the problem , once forward() method called, browser returns 404 resource not found error.

i have followed questions posted on forum , not able solve issue.

can please guide me.

edit: jsp page :

<%@ page language="java" contenttype="text/html; charset=iso-8859-1"     pageencoding="iso-8859-1" import="javax.servlet.*,java.lang.string"%> <!doctype html>  <html>  <head>  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>password reset page</title>  </head> <body> <form method="get" action="resteasy"> <%!string userid;%> <%userid = (string)getservletcontext().getattribute("userid"); %> <p>user id:<%= userid %></p> password: <input type="password" name="pwd" id="pass"> <br> confirm password: <input type="password" name="repwd" id ="c_pass" onblur="confirmpass()"><br> <script type="text/javascript">     function confirmpass() {         var pass = document.getelementbyid("pass").value         var confpass = document.getelementbyid("c_pass").value         if(pass != confpass) {             alert('wrong confirm password !');             document.getelementbyid("c_pass").focus();         }     } </script> <input type="submit" value="submit"> </form>  </body> </html> 

the servlet has deliver jsp :

protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {          log.info("received request popup jsp page");          string userid = request.getparameter("userid");         string utc = request.getparameter("utc");          log.info("recieved userid = "+ userid);         log.info("received utc = "+ utc);           servletcontext requestcontext = request.getservletcontext();         requestcontext.setattribute("userid", userid);         requestcontext.setattribute("utc", utc);           string htmlfilename = null;            try {              htmlfilename =   new deltapropertyhandler(                     deltaconstants.link_html_file).getpropertyvalue(deltaconstants                             .user_password_reset_html);             file file = new file(requestcontext.getrealpath(htmlfilename));             if(file.exists()){log.debug("file exists!!");}             else{log.warn("file mot exist");}          } catch (exception e) {              log.error("failed present jsp page " + e.getmessage());         }        log.info("file name "+htmlfilename);         requestdispatcher rd = requestcontext.getrequestdispatcher(htmlfilename);         rd.forward(request, response);      } 

your code:

requestdispatcher rd = requestcontext.getrequestdispatcher(htmlfilename); 

you should change:

requestdispatcher rd = requestcontext.getrequestdispatcher(programname.jsp);  

if using get method following as:

requestdispatcher view=request.getrequestdispatcher(forward);             view.forward(request, response); 

if using post method as:

private static string list_user="/listuser.jsp";          requestdispatcher view=request.getrequestdispatcher(list_user);         request.setattribute("users", dao.getallusers());         view.forward(request, response); 

user reference format. , @ simple format following as:

  a.jsp> conntroller.java > dao.java>dbutil.java  

you want reference list following link click


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -