Solved

Encode in Java

Posted on 2011-09-13
13
187 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
nestparen challenge 4 56
word0 challenge 3 58
PDFBox - convert image to PDF, PDF resolution 3 70
create a gui in perl 3 45
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now