JavaScript nested Java Implementation JSP

Source: Internet
Author: User

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<base href= "<%=basePath%>" >

<title>my JSP ' index.jsp ' starting page</title>
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This is my page" >
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css" >
-

<body onload= "Ready ()" >
<script>
function Ready () {


<%cookie[] cookies = request.getcookies ();
for (int i = 0; i < cookies.length; i++) {
String key = Cookies[i].getname ();
String value = Cookies[i].getvalue ();

if (key! = null && key.equals ("username")) {
%>
document.getElementById ("username"). value= "<%=value%>";
<%
}

if (key! = null && key.equals ("password")) {
%>
document.getElementById ("password"). value= "<%=value%>";
<%
}
}
%>
}

</script>


<form name= "F1" id= "F1" action= "check.jsp" method= "POST" >
<table>
<tr>
<td>Username:</td>
<td><input type= "text" name= "username" id= "username" ></td>
</tr>
<tr>
<td>Password:</td>
<td><input type= "password" name= "password" id= "password" ></td>
</tr>
<tr>
<TD colspan= "2" ><input type= "Submit" ></td>
</tr>
</table>
</form>
</body>

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<base href= "<%=basePath%>" >

<title>my JSP ' index.jsp ' starting page</title>
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This is my page" >
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css" >
-

<body>
<%
Request.setattribute ("info", "abc");
Request.setattribute ("User", new OBJ ());
String info = (string) request.getattribute ("info");
obj user = (obj) request.getattribute ("User");

String username = request.getparameter ("username");
String Password = request.getparameter ("password");

if (Username.equals ("Adiwood") && password.equals ("Ilovejapan")) {
Request.setattribute ("nickname", "James");
Session.setattribute ("nickname", "Smith");
Session.setmaxinactiveinterval (5);
Request.getrequestdispatcher ("main.jsp"). Forward (request, response);//Forwarding Code
Forwards no data loss, sending data directly inside the server
Cookie UC = new Cookie ("username", username);
Cookie PC = new Cookie ("password", password);

Uc.setmaxage (60*60*24*7);
Pc.setmaxage (3600*24*7);

Response.addcookie (UC);
Response.addcookie (PC);

Response.sendredirect ("main.jsp");//redirect Code
REDIRECT lost data because the client needs to resend the data
}else{
Request.getrequestdispatcher ("login.jsp"). Forward (request, response);
Response.sendredirect ("login.jsp");
}
%>
</body>

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<base href= "<%=basePath%>" >

<title>my JSP ' index.jsp ' starting page</title>
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This is my page" >
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css" >
-

<body>
<%
String user = Request.getparameter ("username");
String nick = (string) request.getattribute ("nickname");

String nick = (string) session.getattribute ("nickname");
Session.getmaxinactiveinterval ();
%>

<a href= "exit.jsp" > Exit </a>
</body>

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%>
<%
String path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<base href= "<%=basePath%>" >

<title>my JSP ' index.jsp ' starting page</title>
<meta http-equiv= "Pragma" content= "No-cache" >
<meta http-equiv= "Cache-control" content= "No-cache" >
<meta http-equiv= "Expires" content= "0" >
<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >
<meta http-equiv= "description" content= "This is my page" >
<!--
<link rel= "stylesheet" type= "Text/css" href= "Styles.css" >
-

<body>
<%
Session.invalidate ();
%>
</body>

JavaScript nested Java Implementation JSP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.