Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to deliver the url string  as a parameter in the url

Posted on 2001-06-03
4
Medium Priority
?
219 Views
Last Modified: 2010-08-05
I want to deliver the url string  as a request parameter to next page ,but the system trucate some information.the part codes are showed as follows.

the html code:
<html>
<body>
<form name="form1" method="post" action="/test/testurl.jsp?url='/servlet/page.go?pagenum=1&pa=adb'&pagerow=3">

   <INPUT TYPE="text" NAME="testname" >

   <INPUT TYPE="submit" NAME="commit" ID="commit" VALUE="commit">
</form>

testurl.jsp:

<html>
<body>
URL test


  <%
      String testname = request.getParameter("testname");
      String url      = request.getParameter("url");
      String pagerow  = request.getParameter("pagerow");
      out.println("testname=" + testname);
      out.println("<br>");
      out.println("url=" + url);
            out.println("<br>");
      out.println("pagerow=" + pagerow);
  %>

</body>


the result page:

<html>
<body>
URL test
  testname=dgdfgdssdgfdsgfsd
<br>
url=/servlet/page.go?pagenum=1
<br>
pagerow=3

</body>

the url string was trucated.Can you give me some advices,Thank you first.
0
Comment
Question by:jianmin
[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
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
ibo earned 400 total points
ID: 6151582
white spaces is not allowed in url (in between parameters)
u can use the method :
java.net.URLEncoder.encode(myString)
to encode special characters and string w/ white spaces
into a valid url.
0
 
LVL 3

Expert Comment

by:ibo
ID: 6151603

and yes.. the single quote is not allowed (special char bot allowed in url addy). use the method i mentioned.

StringBuffer myUrl = new StringBuffer();
myUrl.append("/test/testurl.jsp?url=").append(java.net.URLEncoder.encode('/servlet/page.go?pagenum=1&pa=adb').append("&pagerow=3">);
0
 
LVL 3

Expert Comment

by:ibo
ID: 6151609
..

<form name="form1" method="post" action="<%= myUrl.toString() %>">
0
 

Expert Comment

by:SpideyMod
ID: 8289448
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

688 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