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

JSP中的参数传递方法

(1)利用<jsp:param name="paramName" value="paramValue"></jsp:param>其中name为与属性相关联的关键词,value为属性的值。
    示例:传常量字符串<param name="userName" value="shilei"/>
    示例:传变量 User user=new User("shilei");//User是一个类
    <jsp:param name="user" value="<%=user%>"/>//<%=user%>里面括起来的是jsp表达式
 
(2)利用session.setAttribute("attributeName",attribute)或者request.setAttribute("attributeName",attribute)
    示例:User user=new User("shilei");
    session.setAttribute("userName",user);
 
(3)就像传统的html那样利用表单专递参数。
    示例:<form name="loginForm" action="checkLogin.jsp" method="get">
               <input type="text" name="username">
               <input type="password" name="userpwd">
               <input type="submit" value="提交">
             </form>
 
(4)直接挂在URL后面。示例:response.sendRedirect("checkLogin.jsp?username="+username+"&userpwd="+userpwd"");
String name=request.getParameter("name");
<a href="welcome.jsp?name=<%=name%>">
 
(5)利用cookie对象来传递
Cookie cookie=new Cookie("my","liuliu")
cookie.setMaxage(60*60);(以秒为单位)最大的生命周期
response.addCookie(cookie);
Cookie[] cookies=request.getCookies();(可以通过遍历此数组来访问值)


相关文档:

JSP中表单数据存储的通用方法

朗沃教育成都计算机培训-JSP篇
J2EE(Java 2 Enterprise Edition)技术已广泛应用在Web应用开发中,其中的JavaBean、Servlet技术为开发者提供了更为清晰的开发环境,使用JSP技术表现页面,使用Servlet技术完成大量的业务处理,使用Bean来存储数据及一些业务处理。在WEB应用中,业务数据存储到数据库中的处理工作经常很繁重, ......

JSP 9大对象详解

学习JSP主要学习他的9大对象(request, response, pageContext, session, application, out, config, page, exception ),这些对象都是静态对象,不用定义就可以直接使用,把他们都了解清楚并会运用,就可以在简历上添上一个熟悉技能:JSP
Jsp内置对象 功能 主要方法
out  向客户端输出数据 print() println() flush() ......

JSP实例三、sql分页(1)

index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
& ......

JSP页面EL表达式无效的问题

 以前用WSAD wizard做的,都可以在JSP页面中解析到EL表达式,当然前提是JSP2.0的情况下。
今天遇到了一个莫名其妙的问题。刚下载Eclipse3.3+MyEclipse6.0体验的过程中,遇上了解析不到EL表达式的问题。经过好几个小时的琢磨终于发现了,给大家share一下:
问题就出在建Web Project的时候web.xml声明上。
web.xml ......

JSP 隐式对象

·pageContext:提供对页面属性的访问。
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
pageContext.setAttribute("basePath",basePath);
%>
使用:
${pageScope}
 
·reques ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号