One 、 Conversational Technology

1、 Concept : Share data in one session , stay web Middle finger , A communication between browser and server . Contains multiple requests , And multiple responses .

Data can be shared in multiple requests in a session .

2、 Client session technology :Cookie

Save the data on the client There's not much pressure on the server But the data is not secure ;Cookie By default, it is stored in the browser's memory

// send out cookie:

Cookie c = new Cookie(msg,hehe);


// Accept cookie:

Cookie[] cs = request.getCookies();

if(cs != null){

for(Cookie c : cs){

String name = c.getName();


String value = c.getValue();




// Set up Cookie Life time of , It can be made persistent

setMaxAge(int second):

Positive numbers : On the hard disk

negative : The default value is -1 In browser memory

0: Delete cookie

// Use cookie Deliver Chinese

Cookie uc = new Cookie(username, URLEncoder.encode(username, utf-8));// code

username = URLDecoder.decode(c.getValue(), utf-8);// decode

3、 Server session technology :Session

Save the data in the server Data security The server is under a lot of pressure ;session Depend on cookie There is

//1. obtain session

HttpSession session = request.getSession();

//2. Store the data

session.setAttribute(msg, hehe);

//3. get data

Object msg = session.getAttribute(msg);

// The destruction session


// The destruction session Overtime 30 It's going to be destroyed in a minute




Two 、jsp —— java servlet page

1、 Concept : It's a way to write HTML Language can also write Java Code page ,JSP The essence of Servlet

grammar :

%! int num=1000; % Generated Java The code is in the member position

% System.out.println(hello); % Generated code in service() In the method

%= hello world % out.print(hello word);

%-- jsp Special notes --% notes

2、 Three major instructions : To configure JSP Page properties or import some extra content

%@ Instruction names Property name = Property value %

1)page Instructions


import: Import package


autoFlush: Automatically refresh

buffer: Buffer size

errorPage: Specify the error page

isErrorPage: Whether it's an error page You can use built-in objects exception

2)taglib Instructions

Import extra content

%@ taglib uri= prefix=c %

prefix: Specify label prefix , This thing can be named at will

uri: Specify the uri( Unique identification )

3)include Instructions

Static inclusion %@include file= page % After inclusion , There will only be one .class file

3、 Six action tags

1)jsp:useBean id= Object name class= Package name . Class name scope= Scope of action (request/page/application/session)/

jsp:setProperty name=javaBean object property=javaBean Object property name param=username/

jsp:getProperty name=javaBean object property=javaBean Object property name /

2)jsp: include page=included.jsp flush=true / Dynamic inclusion Multiple .class Bytecode file

3) jsp:forward page=/index.jsp

jsp:param name=msg value=hehe/


4、 Nine built-in objects

1)out Output object Output data to client , Byte stream . Such as out.print(hello);

2)request Request object Receive client's http request

3)response The response object a:addCookie(Cookie cookie); b:sendRedirect(/wel.jsp)

4)session Conversation object getAttribute(String name)

5)application Application object It is ServletContext Class

6)page Page object representative jsp The entity itself , The current page is valid . amount to java Medium this

7)exception Exceptions Represents an exception at run time

8)pageContext Page context object pageContext Object provides the JSP Access to all objects and namespaces on the page

9)config Configuration object jsp Corresponding servlet Configuration of , You can get web.xml The initialization parameter in

Conversation technology and jsp Overview of more related articles

  1. JavaWeb-10( Conversational technology session&JSP)

    JavaWeb- Conversational technology session&JSP Conversation management Session technology One .Session stay WEB In development ,server Can create a session object for each user browser (session object ), notes ...

  2. JSP introduction & Conversational Technology

    One .JSP    1.jsp technology         jsp yes sun Provide dynamic web Resource development technology . In order to solve the problem Servlet Spelling in Chinese html Content css.js The content is very inconvenient ,sun Provides such a technology . if S ...

  3. Conversational Technology : Cookie Session JSP

    ##  Cookie A.. Concept : Client session technology , Save data to client B. Use steps : 1. establish Cookie object , Data binding new Cookie(String  name, String value) ...

  4. JavaEE Dynamic page technology (JSP/EL/JSTL)

    Dynamic page technology (JSP/EL/JSTL) JSP technology jsp Scripts and comments jsp Script : 1)<%java Code %> ----- Inside java Code translation to service Inside the method 2)<%= ...

  5. Conversational Technology ——Cookies and Session Detailed explanation

    Conversational Technology ( One ) summary . Use and classification (1) Basic overview summary : Sessions are multiple requests and responses between the browser and the server in other words , Start with the browser accessing the server , By the end of accessing the server , Multiple requests and ...

  6. Conversational Technology ( Cookie ,Session)

    Conversational Technology :     conversation : The browser accesses the server , Send multiple requests , Accept multiple responses . Until one of them is disconnected . End of session .         solve the problem : You can use conversation Technology , Sharing data between multiple requests in a session .           ...

  7. Java The actual combat 04JavaWeb-03 Conversational Technology

    One . Introduction to conversation Technology 1. What is conversation , Why conversation technology is needed ? conversation : Open a browser from , Visit a website , The process of closing the browser is called a session .http Protocol is stateful . 2. The classification of conversation technology Client storage technology :Coo ...

  8. Conversational Technology cookie and session Detailed explanation

    What is conversation Conversation can be simply understood as : Users open a browser , Click on multiple hyperlinks , Access multiple servers web resources , Then close the browser , The whole process is called a conversation . What problems does conversation technology solve Each user interacts with the server , Each will have a ...

  9. web Basic conversational Technology

    One . Conversational technology Cookie Cookie The technology is to store data to the client 1. How to write a cookie 1) establish Cookie object Cookie cookie = new Cookie(name,va ...

Random recommendation

  1. PHP Magic variable

    PHP  Magic variable PHP A large number of predefined constants are provided to any script it runs . But many constants are defined by different extension Libraries , Only when these extension libraries are loaded , Or after dynamic loading , Or it was included at compile time . There are eight magic tricks ...

  2. Java Collection class source code analysis

    Common class and source code analysis Collection classes Principle analysis Collection   List   Vector Methods of expanding capacity ensureCapacityHelper A lot of methods have been added synchronized Synchronous statement , Come to protect ...

  3. BZOJ 4690 Never Wait for Weights

    Take the right and check the collection 23333333 Be careful dis[x]+=dis[fath[x]. #include<iostream> #include<cstdio> #include<cst ...

  4. LINUX How does the system shut down the firewall ?

    The so-called firewall refers to a combination of software and hardware devices . Between the intranet and the extranet . A protective barrier constructed on the interface between a private network and a public network . It's an image of a way to get security , It is a combination of computer hardware and software , send Internet And Int ...

  5. .Net Core2.0 seckill CMS Deploy to Centos7.3 Pit encountered , How sour

    One .Centos7.3 Installation open VirtualBox, Click New , As shown in the figure below : Click on “ next step ”, The following dialog box pops up , Resize memory , Recommended setting is 2G, It's a little smoother Set it up , Click on “OK”, Click again “ start-up ”, ...

  6. Simple understanding python Using regular expressions

    Regular [Regular Expression]: Regular expressions are often used for retrieval . Replace those that match a pattern ( The rules ) The text of . What is regular for : Regular is used to match strings . Python in string Several methods of : fi ...

  7. 【Code Tools】Java Micro benchmarking tools JMH Introduction to

    One .JMH What is it? JMH It's a Java Tools , Used to build . For operation and analysis Java And other languages written in JVM As the goal of nano/micro/milli/macro The benchmark . Two . basic dos and don'ts 1) function JMH The base ...

  8. Java EE 8 coming

      author Li Shiyao Published on 2014 year 9 month 2 Japan . Estimated reading time : Less than a minute | since 2013 year 6 month Java EE 7 Since its publication ,Java The development team has been planning and collecting the next big release during this period Java EE 8 belt ...

  9. PowerDesigner The table is exported as excel

    PD In the menu bar , In turn, click Tools ->Excute Commands->Edit/Run Script.. fill '*********************************** ...

  10. Stacks And Queues

    Stacks and queues Large scale pit filling site , The first part has not been written yet , above . Stack and queue are very basic data structures , The former is last in first out , The latter is first in first out , Here's the picture : Let's start to separate the client from the implementation , This has two advantages : One is that the client does not know the details of the implementation , But at the same time ...