Link to home
Start Free TrialLog in
Avatar of jianmin
jianmin

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of ibo
ibo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ibo
ibo


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">);
..

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

SpideyMod
Community Support Moderator @Experts Exchange