易截截图软件、单文件、免安装、纯绿色、仅160KB

5月19日 JSP基础

1.ession内的存放的是对象的引用,所以修改内置对象后,不需要重新放置到session中
2.配置Context初始化参数
<Context-param>
<param-name></paran-name>
<param-value></param-value>
<Context-param>
this.getServletContext().getInitParameter(arg0);
-----------------------------------------------------------------------------------------------------------------
3.配置servlet初始化参数
<init-param>
   <param-name></param-name>
   <param-value></param-value>
</inti-param>
ServletConfig config=this.getServletConfig();
config.getParameter(""); 
-----------------------------------------------------------------------------------------------------------------
4配置文件 properties
格式: key=value  其中key不变 value是变化的
例如: #其中"#"为注释
   文件 db.properties
    username=秦焰培
    password=peiaihua 
最好放置到/WEB-INF/db.properties  
 读取属性文件的信息:
 /在web应用中,getServletContext().getRealPath表示的
 是web工程的根路径,
 如:"C:\Program Files\apache-tomcat-6.0.18\webapps\TestURL"
 
 String path=this.getServletContext().getRealPath("");
 FileImputSream fi=new FileInputStream(path);
 Properties pro=new Properties();
 pro.load(fi);
 pro.getProperty("key");
 
 String realPath=this.getServletContext().getResourceAsStream("/WEB-INF/db.properties")
 表示的也是从根路径开始加载文件:
 -----------------------------------------------------------------------------------------------------------------
 <!--  该标签表示服务器启动时,自动创建servlet对象,而且数字越先优先级越高-->
 <Load-on-startup>0,1,2,3,....</Load-on-srartup>
 -----------------------------------------------------------------------------------------------------------------
 servlet通信(communicate):
  路径设置:
&n


相关文档:

Jsp apache common fileupload 文件上传 乱码

在action里使用fileupload时,从reqeust得到的中文数据为乱码,尝试使用了
Java代码
1.   DiskFileItemFactory factory = new DiskFileItemFactory();  
    ServletFileUpload upload = new ServletFileUpload(factory);  
    upload.setHeaderEnco ......

jsp的字符问题

tomcat 默认使用的字符集是ISO-8859-1,不支持中文字符,所以在现实中文时需要转换字符和设置字符集。
server.mxl改为<Connector port="8080" protocol="HTTP/1.1" maxThreads="150" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> ,添加代码转换字符String.getBytes("ISO-8859-1"),"UTF-8 ......

jsp中取得服务器时间并动态显示


<%
      Calendar rightNow = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String sysdate = format.format(rightNow.getTime());
int week = rightNow.get(rightNow.DAY_OF_WEEK);
String weekar ......

JSP 绝对路径 终极解决方案

context.xml 文件夹中
<Context path="/wap"
docBase="D:\IDE\MyEclipse\wap\WebRoot" reloadable="false" >
request.getContextPath(); -==> /wap
this.getServletContext().getRealPath("") ;// D:\IDE\MyEclipse\wap\WebRoot
......

301重定向设置及程序代码实现全集(ASP|.NET|PHP|JSP)

首先申明:这个是我转载的,致力于为像我一样的新手提供帮助!
1、IIS下301设置 Internet信息服务管理器 -> 虚拟目录 -> 重定向到URL,输入需要转向的目标URL,并选择“资源的永久重定向”。
2、ASP下的301转向代码
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanent ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号