Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling JSP pages from a Servlet...having problems there

Status
Not open for further replies.

sidhartha75

Programmer
Apr 25, 2002
2
US

Hi there!!!


It would be very helpful if someone could tell me where do I need to put my JSP page error.jsp..I know when I am working with Personal Web server..but I am having problems with Sambar..I have a Java Server Page called "Error.jsp". A servlet called Membership.java calls this error.jsp when ever a user enters wrong information in the membership form.

Assuming that my "error.jsp" is in the server's root directory which is sambar51 and the servlet membership.java is in servlets directory, what should I give as the path in the code below in redURL.....

What is wrong in this code from Membership.java (this is the servlet)

public void sendError(HttpServlet request, HttpServletResponse response) throws ServletException,IOException{
String redURL="/error.jsp";
RequestDispatcher dispatch=getServletContext.getRequestDispatcher(redURL);
dispatch.forward(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response){

LastName=request.getParameter(FDLname);
if(LastName=null || LastName.trim()=" "){
request.setAttribute("errmsg","Must enter Last name");
sendError(request,response);
}

Can someone tell me if the redURL string for accesing the JSP file error.jsp is correct and what is wrong with the setAttribute code snippet.

A detailed answer with code corrections will be very well appreciated and thanked.
Thanking you in all earnest
Regards
Sidhartha

Thanking you with regards
Sidhartha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top