Solved

Encode in Java

Posted on 2011-09-13
13
210 Views
Last Modified: 2012-05-12
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
Comment
Question by:Swadhin Ray
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 16

Author Comment

by:Swadhin Ray
ID: 36530005
It would be great if some one can give me some sample code to test ...
0
 
LVL 47

Accepted Solution

by:
for_yan earned 250 total points
ID: 36530704
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 36530757
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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 16

Author Comment

by:Swadhin Ray
ID: 36531245
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
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 250 total points
ID: 36531541
use hidden fileds and set the values dont pass the values in URL this is simple way
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36531612
Maybe you can use the POST method then it will not
pass the vlaues thriough the address line
0
 
LVL 16

Author Comment

by:Swadhin Ray
ID: 36533258
@yan .. can you give me some example on values that I have provided?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36533272
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
 
LVL 47

Expert Comment

by:for_yan
ID: 36533316


This shows an example how to pass parameters in the hidden fileds
of the form:
http://www.roseindia.net/jsp/jspsession/HiddenForm.shtml
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 36534069
@yan : why ur repating my answer ?????
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36534847
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
 
LVL 16

Author Comment

by:Swadhin Ray
ID: 36535547
Yes..
0
 
LVL 16

Author Closing Comment

by:Swadhin Ray
ID: 36548399
This really helped me.. thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in @AspectJ Based AOP with Spring 2 18
Java Restore security prompts not working 10 72
Is there a simpler dropbox system? 10 35
spring maven example issues 3 13
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question