随笔分类 - JSP
摘要:用response.sendRedirect(response.encodeURL(url))的好处就是他能将用户的session追加到网址的末尾,也就是能够保证用户在不同的页面时的session对象是一致的. 这样做的目的是防止某些浏览器不支持或禁用了COOKIE导致session跟踪失败
阅读全文
摘要:一、Include指令 <jsp:include>标签表示包含一个静态的或者动态的文件。 语法: <jsp:include page="path" flush="true" /> or <jsp:include page="path" flush="true"> <jsp:param name="paramName" value="paramValue" /> </jsp:include> 注: 1、page=&qu
阅读全文
摘要:<jsp:include page="file/A.txt"></jsp:include>等于<%@include file="file/A.txt"%>
阅读全文
摘要:<%String fileName = application.getRealPath(request.getRequestURI());String fileResPath = new File(new File(fileName).getParent()).getParent();File f = new File(fileResPath, "/file/MyPromise.txt");out.print(f.getAbsolutePath());FileReader in = new FileReader(f);BufferedReader buffer = n
阅读全文
摘要:commom.jsp<%@page import="java.io.*" %><%String fileName = application.getRealPath(request.getRequestURI());String rootPath = new File(new File(fileName).getParent()).getParent();%>
阅读全文
摘要:自从Tomcat5.x开始,GET和POST方法提交的信息,Tomcat采用了不同的方式来处理编码,对于POST请求,Tomcat会仍然使用request.setCharacterEncoding方法所设置的编码来处理,如果未设置,则使用默认的iso-8859-1编码。而GET请求则不同,Tomcat对于GET请求并不会考虑使用request.setCharacterEncoding方法设置的编码,而会永远使用iso-8859-1编码。解决办法如下:1.配置tomcat的配置文件server.xml里这句:<Connector URIEncoding="GB2312"
阅读全文