`
nopain_nogain
  • 浏览: 16091 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Reading Of JSP

阅读更多

servlet的生命周期:

          从始致终只有一个对象,第一次请求的时候初始化一遍(constructer),只一遍,然后调用init方法,也是只一遍,然后以多线程的方法处理请求(调用doGet()、doPost()),最后在卸载的时候,调用destory()方法.

 

session和cookie的区别:

                session                                                          cookie

           运行在服务器端                                              运行在客户端

                 安全                                                                不安全

           文件大小没有限制                                     文件大小有限制,最大不能超过4k

两种实现方式(依赖于cookie、URL重写)        两种类型(有生命周期、无生命周期)

 

<jsp:forward page="target.jsp"/>和response.sedRedrict("要转向的页面")的区别:

          <jsp:forward page="target.jsp"/>                  response.sedRedrict("target.jsp")

                转向后,后面的语句将不在执行                             转向后,后面的语句将继续执行        

                          地址栏没有变化                                               地址栏有变化

                               速度快                                                           速度慢

         转向的目标页面紧限于application内部                   可以转向任何页面(google、linuxsir等)

                           可以带参数                                                      可以带参数

 

<@ include file="_include.jsp">和<jsp:include page="_include.jsp" flush="true"/>的区别:

              <@ include file="_include.jsp">              <jsp:include page="_include.jsp" flush="true"/>

          在JSP页面转译的时候就已经将程序嵌入,                         在执行到此条语句时在将被包含页面转译

                          常用                                                                             不常用

                       不可以带参数                                                                  可以带参数

 

JSP内置对象:

         out、request、response、application、exception、session

 

解决乱码问题:

页面本身有中文的时候(servlet

resp.setContentType("text/html;charset=gbk");

注意:一定要写在PrintWriter out = resp.getWriter();之前

页面本身有中文的时候(JSP

<%@ page contentType="text/html;charset=gb2312"%>

解决get方式乱码问题(Tomcat):

修改server.xml àURIEncoding="GBK"

post方式提交内容的乱码

request.setCharacterEncoding("GBK");

注意:一定要写在存取第一个参数之前   

注意:不要调用response.setCharacterEncoding("GBK");

<jsp:param name="user" value="<%=s%>"/>url地址包含中文参数

<%request.setCharacterEncoding("GBK");%>

 

            

 

分享到:
评论

相关推荐

    基于jsp医院药品查询系统源码.zip

    instead of reading a lot of books information, the main functions of the system include: continent information management, information management, national educational institutions of traditional ...

    abLoginServlet.zip

    Servlet操作数据库jdbc增删改查,jsp页面显示(MVC思想) 1、Servlet和JSP简介:  Java开发Web应用程序时用到的技术主要有两种,即Servlet和JSP,Servlet是在服务器端执行的Java程序,一个被称为Servlet容器的程序...

    解决Invalid byte 1 of 1-byte UTF-8 sequence

    标签 "tomcat" 提示问题与Apache Tomcat有关,Tomcat是一个流行的Java应用服务器,用于部署和运行Java Servlet和JavaServer Pages(JSP)应用程序。在处理XML配置文件或其他包含非ASCII字符的资源时,Tomcat可能会...

    实验1 JSP程序设计1.doc

    Hobbies: &lt;input type="checkbox" name="hobbies" value="reading"&gt; Reading &lt;input type="checkbox" name="hobbies" value="coding"&gt; Coding &lt;input type="checkbox" name="hobbies" value="traveling"&gt; ...

    Spring 5 Design Patterns-Packt Publishing(2017).pdf

    readers should have basic knowledge of Core Java, JSP, Servlet, and XML. Spring 5 Framework is newly launched by Pivotal with reactive programming. Spring 5 introduces many new features and ...

    JSP_struts2标签大全.doc

    ,'music','reading'}" /&gt; ``` - **说明**: 生成一组复选框,用于多选列表。 9. **combobox** - 创建下拉选择框。 - **示例代码**: ```xml ,'USA','UK'}" /&gt; ``` - **说明**: 生成一个下拉选择框,用于单选...

    pro spring 2.5

    I vividly remember cringing when updating all the JSP form tags, knowing that I was creating yet more work for Jan. With the 2.5 release just on the horizon, Jan made the sensible choice to forego a ...

    spring-boot-reference.pdf

    JSP Limitations 28. Security 28.1. MVC Security 28.2. WebFlux Security 28.3. OAuth2 28.3.1. Client 28.3.2. Server 28.4. Actuator Security 28.4.1. Cross Site Request Forgery Protection 29. Working ...

    二十三种设计模式【PDF版】

    Most developers claim to experience an epiphany reading this book. If you've never read the Design Patterns book then you have suffered a very serious gap in your programming education that should be...

    Developing Flex Applications 910p dda_doc88_cracker.zip

    Changing the appearance of a component at runtime . . . . . . . . . . . . . . . . . . . . . . 99 Extending components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

Global site tag (gtag.js) - Google Analytics