怎么可以给一个url传参数了,同时又跳转回之前的页面呢?意思就是,我要给一个网络地址传递一个参数,但是那个接收页面是我无法控制的,我想传递参数后直接跳转到本页或者之前的页面,该如何做问题解决了,另开帖送分

解决方案 »

  1.   

    把要跳转的地址用URLEncode.encode一下,
    如:
    url=http://my.com/my.jsp
    http://my.com/test.jsp?url=URLEncode.encode("http://my.com/my.jsp")
    ;//也可以设置编码
    就可以把url取得了
      

  2.   

    http://yourserver/your.jsp?id=hello
    在your.jsp中:
    <%
       String str;
       str=request.getParameter("id");
       response.sendRedirect("other.jsp?id="+str);
    %>
      

  3.   

    你可能没明白我的意思,我现在要做的是,我给一个远程的地址传递参数,那个远程的页面是asp写的,我要求,可以给那个远程的页面传递参数,但是并不会跳转过去~~~
    就是仍保持当前页面内容或者在向后退一个页面
      

  4.   

    MYLiao(醉夕阳) :我并不能更改接收的页面,既只是传递参数,并不跳转到接收的页面
      

  5.   

    据说这个
    URLConnection类可以用但是,看了半天还是不明白
      

  6.   

    <A class=link7 onclick="postvalue(<%=idvalue%>);" href="my.jsp?id=<%=idvalue%>">
    <script language="JavaScript">
    function postvalue(str){
        alert("http://otherserver/xxx.asp?id="+str.value());
    };
    </script>
      

  7.   

    <A onclick="postvalue()" href="my.jsp?id=<%=idvalue%>">
    <script language="JavaScript">
    function postvalue(){
        alert("http://otherserver/xxx.asp?id="+<%=idvalue%>);
    };
    </script>
      

  8.   

    写个类,向远程那个URL发请求,返回的response你不处理就行
      

  9.   

    问题解决
    import java.net.*;
    import java.io.*;
    /**
    用POST 方式发送数据 然后从结果中读取
    FileName:SocketURLConnection.java
    @Author:peigen lee
    Date:2005-12-15
    */public class DoPostURLConnection
    {
    public static void main(String args[])
    {
    try{URL url = new URL("http://localhost:8888/97741/815/formAction.asp");
    URLConnection uc = url.openConnection();
    uc.setDoOutput(true);OutputStream raw = uc.getOutputStream();
    OutputStream buf = new BufferedOutputStream(raw);
    OutputStreamWriter out = new OutputStreamWriter(buf,"GBK");
    out.write("myName=Alec Cheung&[email protected]");
    out.flush();
    out.close();InputStream in = uc.getInputStream();
    in = new BufferedInputStream(in);
    Reader r = new InputStreamReader(in);
    int c;
    System.out.println("==================Beging====================");
    while((c = r.read()) != -1)
    System.out.print((char) c);
    in.close();
    System.out.println("===================End======================");
    }
    catch(IOException e){
    ///
    }
    }
    }
      

  10.   

    比如你现在的页面是:
    http://my.com/myweb/my.jsp
    你要将此url传给http://myasp.com/my.asp,让它能跳转回来,那么:只要链接如此就行:http://myasp.com/my.asp?url=http://my.com/myweb/my.jsp
    但是由于参数url中有特殊字符,所以要转义:
    url=URLEncode.encode("http://my.com/myweb/my.jsp",charset)默认charset是iso-8859-1,你可以根据自己服务器配置来