[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Encode in Java

Posted on 2011-09-13
13
Medium Priority
?
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Independent Software Vendors: 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!

 
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 1000 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

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!

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

649 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