[Java] JSP

background

  • Write java code in html

Implementation process

  • The hello.jsp  translated into hello_jsp.java (\ tomcat \ work \ Catalina \ localhost \ _ \ org \ apache \ jsp)
  • hello_jsp.java is a servlet (inherited  HttpServlet )
  • The hello_jsp.java  compiled into hello_jsp.class
  • Execution hello_jsp, generate html
  • Html http protocol by the response back to the browser
1 <%@page contentType="text/html; charset=UTF-8"
2     pageEncoding="UTF-8" import="java.util.*"%>
3 你好 JSP
4 <br>
5 <%=new Date().toLocaleString()%>
View Code

 

 

Cookie

  • Cookie is a way of browser and server interaction data
  • Cookie is created by the server to the browser, the browser is stored in the user's local hard drive (Windows directory Cookie folder)
  • The next time access to the site, it will put the Cookie sent to the server
  • By Cookie, the website can recognize you are a first time visit, or access it again
  • Some sites when landing, there will be an option, or ask you to keep log-in status within a month if you want one week
  • If you choose, then within a week, do not need to enter the account password, this function is achieved by Cookie

 

 Session

  • Session is a session corresponding Chinese translation
  • Refers to the open browser from a user visits a website to start, no matter how many pages are visited on this site, click on the many links until the user closes the browser so far, all belong to the same session
  • It is a request for a particular user, stored on a web server in a global variable
  • With it we can put some of the information stored on the user's server without passing back and forth between server and client
  • Each user on the server to save a session, each session has an id as identity
  • jsessionid variable is used to store client session id, the client saved along with other variables in a cookie
  • General cookie variable different, jsessionid cookie is held in memory of the destruction when closing the browser window
  • service session end after a period of time without failure, Tomcat default configuration 30 minutes
  • May be configured to be adjusted by the session-config /tomcat/conf/web.xml
  • setSession.jsp
    • session.setAttribute("name", "teemo");
  • getSession.jsp
    • session.getAttribute("name");

 

Guess you like

Origin www.cnblogs.com/cxc1357/p/12517459.html
jsp