![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Jsp&Servlet
wjt276
这个作者很懒,什么都没留下…
展开
-
在jsp里面怎么样获得提交请求页面地URL
在编写JSP/Servlet应用时常常需要从传入的链接中提取一些信息。HttpServletRequest提供了多个方法,这些方法之间容易混淆。总结并举例如下,希望能对大家有所帮助。 举例: http://localhost:7001/myservlet/somepath/test?someparam=somevalue request.getPathInfo():...原创 2010-01-02 17:03:48 · 135 阅读 · 0 评论 -
Cookie、Session学习笔记
Cookie、Session学习笔记原创 2010-06-12 10:50:44 · 94 阅读 · 0 评论 -
post中文乱码
request.setCharacterEncoding("GB18030"); // response.setContentType("text/html;charset=GB18030"); 但是要求在,第一个获取之前设置。否则无效原创 2010-06-10 14:44:19 · 98 阅读 · 0 评论 -
GET方式提交数据,读取中文乱码问题
* String carType = request.getParameter("carType"); * //首先对数据进行还原成ISO8859_1,然后重组成GB18030或是GBK或是GB2312 * carType = new String(carType.getBytes("ISO8859_1"),"GB18030");...原创 2009-08-24 07:05:28 · 86 阅读 · 0 评论 -
JSP获取当前系统时间
new java.util.Date(System.currentTimeMillis())原创 2009-08-24 07:04:13 · 256 阅读 · 0 评论 -
获取当前页面的URL和所有参数,以便上页面的参数可以完整传入下页面
[code="java"]String url = request.getRequestURL() + (request.getQueryString() == null ? "" : "?" + request.getQueryString());[/code]原创 2009-08-24 06:59:57 · 122 阅读 · 0 评论 -
Jsp数据库二级联动原理
数据库二级联动构思:利用AJAX访问servlet来完成 * 第一、父级列表由页面初始完成 * 并加上onchange="javascript:getData(this.value)"事件 * 注意:getData(obj)为AJAX访问servlet函数,具体见代码jslib/linkage.js * 第二、在servlet中返回数据时,要求采用XML,如: [code...2009-08-21 22:39:19 · 194 阅读 · 0 评论 -
在jsp页面中获取项目名称
java代码 [code="java"] String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //System.out.println("...原创 2009-08-21 22:34:35 · 154 阅读 · 0 评论 -
JSP页面重定向和页面转发的区别
一、页面重定向 页面重定向可以调用函数: [code="Servlet"] response.sendRedirect("xx.jsp");[/code] 页面重定向时request和response的信息都丢失了,它是重新发起一个定向请求,和原先的没有关系了.由于它是新的定向请求,所以效率不高。页面转向可以用在同一个应用中,也可以用在不同应用中。也就是说redire...2009-08-19 10:13:49 · 157 阅读 · 0 评论 -
request.getRealPath()
request.getRealPath("") 就是取得你当前运行文件在服务器上的绝对路径. request.getRealPath("/") 取得当前站点的根目录. request.getRealPath() 方法现在已经过期,目前推荐使用下面的方法: request.getSession().getServletContext().getRealPath(""); 或是...原创 2010-07-06 10:25:39 · 115 阅读 · 0 评论