Home > Web Front-end > JS Tutorial > body text

How to get the value in session in js

coldplay.xixi
Release: 2023-01-03 09:29:36
Original
19688 people have browsed it

JS method to obtain the value in the session: 1. You can make an AJAX request to the server and return the value in the session; 2. You can use the tag [<%=%>] in JSP to Get the value in session.

How to get the value in session in js

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

JS method to get the value in session:

session is the server object,

javascript is the client script, the operation you can do is to This value is output to the javascript of the page to participate in the operation using

<%=%>, but cannot be directly called with js

Method:

You can make an AJAX request to the server and return the value in the session.

Of course you can also use <%=%> in JSP to get the value in the session, for example:

 <script language="JavaScript"> 
  function getMyName(){ 
     var myName="<%=session.getAttribute("MYNAME")%>"; 
     alert(myName); 
  }
Copy after login

Related free learning recommendations: javascript video tutorial

The above is the detailed content of How to get the value in session in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template