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

  • Home
  • SEARCH
  • 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 9183395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:47:31+00:00 2026-06-17T18:47:31+00:00

Am using a HTML form like this, <form action=/myservlet?userid=12345 method=post enctype=multipart/form-data> <input type=file name=file>

  • 0

Am using a HTML form like this,

<form action="/myservlet?userid=12345" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" value="Submit">
</form>

And the path of this HTML form is say for example, http://www.mywebapp.com/sample.html

In my servlet when i use the String url = req.getRequestURL().toString(); and printout the string it prints the form action URL http://www.mywebapp.com/myservlet?userid=12345 and not the HTML URL.

The expected HTML URL : http://www.mywebapp.com/sample.html (from here only i request and i need this URL)

Can anyone suggest me how to get the HTML url path in the servlet.

  • 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-06-17T18:47:32+00:00Added an answer on June 17, 2026 at 6:47 pm

    If I understand you correctly you want to get the URL of one request (the request that loaded the html) when you make a subsequent request (the form post).

    HTTP is stateless and therefore there is no way to reliably do this.

    Needing to do this has a bit of a whiff of a code smell about it, but if you really need the URL you’re going to have to pass the URL as a hidden input in the form. There’s various ways to do this, whether you use JSP/JSTL or do something client side with JavaScript, but basically you trying to get a form like this:

    <form action="/myservlet?userid=12345" method="post" enctype="multipart/form-data">
       <input type="file" name="file">
       <input type="hidden" name="url" value="http://www.mywebapp.com/sample.html"/>
       <input type="submit" value="Submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a CheckBoxList within a form, like this... @using (Html.BeginForm("Save", "Product", FormMethod.Post))
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,
I have a webpage with a form, which looks kinda like this: @using (Html.BeginForm(MyAction,
In my ASP MVC 3 application, I have this form @using (Html.BeginForm()) { <input
I have a form like this: <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <% using (Html.BeginForm(Edit, Order,
I have a MVC web application with a logout form like this: @using (Html.BeginForm(LogOff,
So I'm using this HTML form for a simple search field <form action =
I am using an html form that submits data to a MYSQL database. I
I have a form like below:- <% using ( Html.BeginForm(search, home, FormMethod.Get) ) {
This is the row I'm having problems with: <% using(Html.BeginForm(Create#result, Report, FormMethod.Post)) { %>

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.