response.sendRedirect("pleaselogin.jsp?errorMessage=1");
这样就可以了,传的参数接在后面。
这样就可以了,传的参数接在后面。
解决方案 »
- 调用function问题
- 一个resultset问题,奇怪
- 关于form to entity 的一个问题。
- 提示出错::[Microsoft][ODBC 驱动程序管理器] 无效的游标状态 !非常急~
- 我晕了 !用jsp做前台 后台用sqlserver2000怎么也连不上 请各位大虾帮忙啊!!小地感激不尽
- TOMCAT 5.5服务起不来,怎么办?
- 求助啊,哥哥姐姐们Help啊~~~我菜菜啊
- java Connection的commit()问题
- 【打扰了】如何生成不重复的随机数?
- 关于图片路径的问题
- JAVA如何读word的doc文档!谢谢!
- 关于数据库连接的错误,我弄了好久都没有办法解决。解决了50分。不够再加,在线等待。。。
----------
import java.io.*;
import java.net.*;public class URLWrapper
{
/**
* 发送http网络请求.<br>用编程方式发送一个http网络请求到目的链接, 如果发送成功返回服务器响应字符串
*
* @param href 链接
* @param method 方法
* @param params 参数
* @return 服务器响应返回的字符串
* @throws 所有异常
*/
public static String sendHttpRequest(String href, String method, String params) throws Exception
{
//System.out.println("URLWrapper.sendHttpRequest begin");
// 创建http连接
URL url = new URL(href);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 设定发送方法
conn.setRequestMethod(method);
// 写入参数
conn.setDoOutput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.println(params);
out.close();
// 获得服务器返回字符串
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuffer sb = new StringBuffer();
String line = "";
while ((line = in.readLine()) != null)
{
sb.append(line + System.getProperty("line.separator"));
}
in.close();
//System.out.println("URLWrapper.sendHttpRequest end");
return sb.toString();
}
}
----------
in servlet or jsp
----------
import java.util.*;String url = "http://localhost:8080/site/index.jsp";String method = "POST";String params = "";// 注意,没试过如果有同名属性的状况
Map map = request.getParameterMap();
for ( Iterator it = map.keySet().iterator(); it.hasNext(); )
{
String name = it.next().toString();
params += "&" + name + "=" + map.get(name).toString();
}out.println(URLWrapper.sendHttpRequest(url, method, params));----------