JSP操作技巧(摘自www.java-cn.com)

JSP操作技巧(摘自www.java-cn.com)

 

1 表单的另一种参数传递方法:

 

 

2 防止为登陆浏览:

if(session.getAttribute("UserName")==null||session.getAttribute("UserName")=="")

 

{

 

out.println("");

 

}

 

else

 

{

 

%>

 

3验证 用户信息的合法性:

 

<%@ page language="java" import="java.sql.*" %>

 

 

<%! String bookid,bookNumS; int Id,bookNumI;

 

%>

 

<%

 

bookid=request.getParameter("bookid");//得到ID

 

bookNumS=request.getParameter("bookfield");//得到数量

 

if(bookNumS!=""&bookNumS!=null)

 

{

 

try

 

{

 

       bookNumI=Integer.parseInt(bookNumS);//转换成int类型

 

       Id=Integer.parseInt(bookid) ;

 

}

 

catch(NumberFormatException e)

{

       out.println("");

}

boolean one=bookM.bookQuery(Id,bookNumI,""+session.getAttribute("loginTime"),""+session.getAttribute("UserName"));

 

if(one)

 

{

       out.println("");

}

else

 

{

       out.println("");

}

}

bookM.bclose();

}

%>

4表单的检验

确定" οnclick=search_sub()>

/n"))));

}

catch(Exception e)

{

System.out.println(e.toString());

}

}

3javaBean 返回

public static void goback(JspWriter out)

{

try

{

out.print("/n");

}

catch(Exception e)

{

System.out.println(e.toString());

}

}

4bean 插入javascript

public static void goback(JspWriter out)

{

try

{

out.print("/n");

}

catch(Exception e)

{

System.out.println(e.toString());

}

}

 

你可能感兴趣的:(JSP,jsp,string,javascript,exception,null,出版)