I have an index.jsp page which uploads an image. On submit it goes to a servlet Upload.java. In the servlet I am checking if the extension in of image("jpg","png",etc) and forwards to new jsp page else it shows an error message and includes the same index.jsp page.
My servlet is a package named "servlets".
If I select an image then it is working properly. But if I select any file other than image then it shows the error with the index.jsp page as intended. Till now it works fine but if I upload any file even image from here, the server complains.
Here is how I am including the index.jsp page in UploadServlet.java servlet.
out.println("This type of file is not allowed. Please select an image.");
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
dispatcher.include(request, response);
Here is the error from the server when I try to upload the image second time.
HTTP Status 404 - /UploadImage/servlets/servlets/UploadServlet
type Status report
message /UploadImage/servlets/servlets/UploadServlet
description The requested resource (/CropImage/servlets/servlets/UploadServlet) is not available.
Apache Tomcat/6.0.13
It is appending the servlet's package name to the url.
How to solve this problem?