Solved

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

Posted on 2001-06-03
4
206 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
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
ibo earned 100 total points
Comment Utility
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
Comment Utility

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
Comment Utility
..

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

Expert Comment

by:SpideyMod
Comment Utility
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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 …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

771 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

10 Experts available now in Live!

Get 1:1 Help Now