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.

LVL 17
Swadhin RaySenior Technical Engineer Asked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
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
 
Swadhin RaySenior Technical Engineer Author Commented:
It would be great if some one can give me some sample code to test ...
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
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 NConnect With a Mentor ArchitectCommented:
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 NArchitectCommented:
@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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.