Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:26:43+00:00 2026-05-25T12:26:43+00:00

I have an index.jsp page which uploads an image. On submit it goes to

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:26:43+00:00Added an answer on May 25, 2026 at 12:26 pm

    Apparently you’re using a relative action URL in your <form>.

    <form action="servlets/UploadServlet" ...>
    

    When you open index.jsp, the request URL is

    http://localhost:8080/UploadImage/index.jsp

    When you submit the form, the action URL is relative to the current folder, so request URL will be

    http://localhost:8080/UploadImage/servlets/UploadServlet

    When you submit the form once again, the will be still relative to current folder, so you end up in

    http://localhost:8080/UploadImage/servlets/servlets/UploadServlet

    You need to fix it to be a domain-relative URL, starting with a leading slash.

    <form action="/UploadImage/servlets/UploadServlet" ...>
    

    This way the URL will be resolved relative to the domain root. You can also resolve the context path dynamically by ${pageContext.request.contextPath}:

    <form action="${pageContext.request.contextPath}/servlets/UploadServlet" ...>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have index.jsp from which I get the parameters to servlet LoginServlet.java The servlet
So I have a main JSP index page, index.jsp, which has several includes. Something
I have my index page which posts a single entry instead of the usual
At current i have an index page which shows values from an XML page
iam having a jsp page Index.jsp which accept a only unicode string as its
I have a JSP page on which I have a div tag in which
I have a app engine app (java) which renders a page. It fetches data
I have a web.xml which looks like: <web-app> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <security-constraint> <web-resource-collection> <web-resource-name>Default</web-resource-name>
I have this DIV on my application jsp page which I need to inject
I have a popup using div and javascript in a jsp page which also

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.