This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I want to make static URL

 
Farakh khan
Ranch Hand
Posts: 833
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My servlet URL is changing options and URL is like:

doGet method is used to retriew the relevant data.

Question:
=========
I want that URL should not be changed like doPost method and URL should remain as it is when it was displayed first time

Thanks in anticipation

Best regards

 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a hidden field on form and have the value as per the requirement.
This hidden value will be passed to servlet as a part of header and will not b shown in url if you will use the post method
 
Farakh khan
Ranch Hand
Posts: 833
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harpreet Singh janda wrote:You can have a hidden field on form and have the value as per the requirement.
This hidden value will be passed to servlet as a part of header and will not b shown in url if you will use the post method


You are right but I am accessing directly the URL through doGet method as doPost is not supporting direct access from URL

Is there anyway else around?

Best regards
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want the servlet to respond to POST requests, then it has to have a doPost() method. Parameters in a GET request are included in the query string portion of the URL. Parameters in a POST request are included in the body of the request and do not appear in the URL.
 
Farakh khan
Ranch Hand
Posts: 833
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Angstadt wrote:If you want the servlet to respond to POST requests, then it has to have a doPost() method. Parameters in a GET request are included in the query string portion of the URL. Parameters in a POST request are included in the body of the request and do not appear in the URL.


I didn't want to use POST requests but looking for the way if possible to hide the URL.

best regards
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Farakh khan wrote:I didn't want to use POST requests but looking for the way if possible to hide the URL.


Where are you accessing these URLs from? A form? A link? Can you provide an example of how you are using these URLs?
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why do you want to hide the URL?
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

I think there might be a few ways you could get around this, you could use javascript to make an AJAX request to get the data so that the page doesn't change. You could also send a redirect back to the plain url and stored something in the session that the servlet picks up.

I wouldn't use either of these though, why are you not just using a POST?

Sean
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:Hey,

I think there might be a few ways you could get around this, you could use javascript to make an AJAX request to get the data so that the page doesn't change. You could also send a redirect back to the plain url and stored something in the session that the servlet picks up.

I wouldn't use either of these though, why are you not just using a POST?

Sean
Indeed, AJAX it's a good call.

You could also just use one Servet in your app and set the diference by a hidden attribute.

Let's say, for login jsp you could use "userLoing" then to list something "somethingList". By doing this, you will always remain with the same URL.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sean Clark wrote:...why are you not just using a POST?

It's true that using the POST method would prevent the request parameters from appearing in the URL. But we don't know why Farakh wants to do that. Using the POST method might not solve the actual problem; I don't consider showing request parameters in the URL to be a problem, but Farakh does. Again, we don't know why.
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I don't consider showing request parameters in the URL to be a problem, but Farakh does.


I can think of one reason why using GET can be a security risk: A login form that uses GET would put the username and password in the URL. Even if the connection is secure (https), this makes the password visible to anyone who is standing over the user's shoulder (does https encrypt the URL too? If not, then the information is visible to packet sniffers too). Also, because the browser's history saves every URL the user visits, the user's login information will be saved there, allowing anyone who has access to that computer to get this information.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Angstadt wrote:
Paul Clapham wrote:I don't consider showing request parameters in the URL to be a problem, but Farakh does.


I can think of one reason why using GET can be a security risk: A login form that uses GET would put the username and password in the URL...


Yes, that's certainly true. You definitely want to use POST there, and https as well. But it doesn't resemble Farakh's initial post though. I'm waiting for a description of the real problem.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic