• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Encode in Java

Hello Experts,

I need to encode  URL :  url="SummaryPage.do?Id=-1&qType=quote";   in JAVA.

Currently showing like:

http://localhost:****/SummaryPage.do?Id=-1&qType=quote

The result should be like:

http://localhost:****/SummaryPage.do?quote


And also how to decode it.

0
Swadhin Ray
Asked:
Swadhin Ray
  • 5
  • 4
  • 2
  • +1
2 Solutions
 
Swadhin RaySenior Technical Engineer Author Commented:
It would be great if some one can give me some sample code to test ...
0
 
for_yanCommented:
I am not sure waht you mean but look at the code at accepted siolution here, maybe it will help:
http://stackoverflow.com/questions/724043/http-url-address-encoding-in-java



0
 
CEHJCommented:
You really need to look into what URL encoding means. Your two examples do not relate to each other, and at a quick glance, the first one doesn't need encoding
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Swadhin RaySenior Technical Engineer Author Commented:
My java code is something like below:

 url="SummaryPage.do?Id=-1&qType=quote";


Now when I open the main URL it will be like :

http://localhost:<<port>>

When I click on summary page button it redirect me to another page and the URL looks like :

http://localhost:<<port>>/SummaryPage.do?Id=-1&qType=quote


Where I want to encode the below:

http://localhost:****/SummaryPage.do?quote

So that I dont have to show the user the ID number and the type of request type.


Can any give me the example on my requirement.  





0
 
Sathish David Kumar NCommented:
use hidden fileds and set the values dont pass the values in URL this is simple way
0
 
for_yanCommented:
Maybe you can use the POST method then it will not
pass the vlaues thriough the address line
0
 
Swadhin RaySenior Technical Engineer Author Commented:
@yan .. can you give me some example on values that I have provided?
0
 
for_yanCommented:
You use the form with hidden elements and in its action you specify method=POST
and for hidden element you specify their names Id and qType and their
values -1 and quote respectively and when you submit such form and
say in the servlet specified in the action method you'll retrieve
your values the same way as you would retrieve them from the
GET method if they were present in the address line
0
 
for_yanCommented:


This shows an example how to pass parameters in the hidden fileds
of the form:
http://www.roseindia.net/jsp/jspsession/HiddenForm.shtml
0
 
Sathish David Kumar NCommented:
@yan : why ur repating my answer ?????
0
 
CEHJCommented:
A combination of http:#36531541 and http:#36531612 should do it for you. Nothing to do with encoding btw - you mean you want to hide the parameters
0
 
Swadhin RaySenior Technical Engineer Author Commented:
Yes..
0
 
Swadhin RaySenior Technical Engineer Author Commented:
This really helped me.. thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now