JSLT获取session的值

设置session:


String name = request.getParameter("name");
String password = request.getParameter("password");
session.setAttribute("name",name);                                                                                                                                                                                                                                                                                                                                                                             
session.setAttribute("password",password);
if(jdbctest.login(name, password))
{
    out.println("登录成功");
    out.println("====");
    response.sendRedirect("index.jsp");
}
else
{
  //生成页面响应
  out.println("====");
  //重定向到error.jsp页面
  response.sendRedirect("error.jsp");

}


使用JSLT获取session的值:

先在JSP开头写上:

  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>  (c标签的包)
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> 




或者直接使用:
${sessionScope.UserInfo.userName}


servlet中,通过url上传参,jsp中,使用param获取参数。

例如:

 servlet中:response.sendRedirect("buyer/udai_integral.jsp?allIntegral="+allIntegral);   

 jsp中: ${param.allIntegral}


url的默认对象为:param

你可能感兴趣的:(JavaScript,JSTL,获取session值,param获取url参数)