Solved

passing a variable in the address bar

Posted on 2004-08-05
3
257 Views
Last Modified: 2010-04-01
How can I pass the variable name to the next page through the address bar? The way ive been trying will not pass anything after the blank space between the firstname and lastname

name = "adro ron";
out.print("<form name='Form1231' method='post' action="+request.getContextPath()+"/allocate_actualtime.jsp?customername="+firstnames[cnt]+lastnames[cnt]+"&names="+name+">");
Thanks
0
Comment
Question by:ram_os
[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
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 100 total points
ID: 11725133
You need to encode the spaces into a form that browsers can handle :-)

String name = java.net.URLEncoder.encode( "adro ron", "UTF-8" ) ;
String customername = java.net.URLEncoder.encode( firstnames[cnt]+lastnames[cnt], "UTF-8" ) ;
out.print("<form name='Form1231' method='post' action="+request.getContextPath()+"/allocate_actualtime.jsp?customername="+ customername +"&names=" + name + ">");
0
 

Author Comment

by:ram_os
ID: 11726496
Thanks Tim, that worked....

Could you explain your code plz and why I needed to do it, if you dont mind,
Thanks again
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11726573
Yeah, sure :-)

You basically, can't have any special characters, spaces, "?"s, or "&"s in your parameters, as the browser will think they are gaps in the url, or the start of a parameter list or the next parameter, etc

So...

You have to encode the parameters so that they get read correctly by the browser

The way to encode things is like this:

%XX

where XX is the ascii value of the special character

So " " becomes "%20"

and URLEncoder.encode does this for you :-)

Hope you understand :-)

Glad I could help :-)

Tim
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
some methods private some are not 8 221
maven set up 2 188
struts hibernate integration example 28 147
I get error: useBean: Duplicate bean name: {0} 1 161
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 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