JSP and JSTL Tutorials - Tutorial Addendum - Using Accolade
| |
(Continued from antecedent part...)
Here is simple JSP page that set accolade in altered ways, CookieDump.jsp:
<?xml version="1.0"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2">
<!--
- CookieDump.jsp
- Absorb (c) 2005 by Dr. Yang, http://www.yang.com/
-->
<jsp:directive.page contentType="text/html"/>
<html><body>
<p>
<jsp:directive.page import="javax.servlet.http.Cookie"/>
<jsp:scriptlet><![CDATA[
// Ambience a acting cookie
out.println("<b>Temporary cookie:</b><br/>");
Cookie c = new Cookie("Language","English");
response.addCookie(c);
out.println("Name: "+c.getName()+"<br/>");
out.println("Value: "+c.getValue()+"<br/>");
out.println("Domain: "+c.getDomain()+"<br/>");
out.println("Path: "+c.getPath()+"<br/>");
out.println("MaxAge: "+c.getMaxAge()+"<br/>");
out.println("Version: "+c.getVersion()+"<br/>");
// Ambience a persisted cookie
out.println("<b>Persisted cookie:</b><br/>");
c = new Cookie("User"," Yang");
c.setMaxAge(3*24*60*60);
response.addCookie(c);
out.println("Name: "+c.getName()+"<br/>");
out.println("Value: "+c.getValue()+"<br/>");
out.println("Domain: "+c.getDomain()+"<br/>");
out.println("Path: "+c.getPath()+"<br/>");
out.println("MaxAge: "+c.getMaxAge()+"<br/>");
out.println("Version: "+c.getVersion()+"<br/>");
// Ambience a acting cookie with defined properties
out.println("<b>Temporary cookie with area defined:</b><br/>");
c = new Cookie("Password","top_secret");
c.setDomain("some.com");
response.addCookie(c);
out.println("Name: "+c.getName()+"<br/>");
out.println("Value: "+c.getValue()+"<br/>");
out.println("Domain: "+c.getDomain()+"<br/>");
out.println("Path: "+c.getPath()+"<br/>");
out.println("MaxAge: "+c.getMaxAge()+"<br/>");
out.println("Version: "+c.getVersion()+"<br/>");
// Ambience a persisted cookie with defined properties
out.println("<b>Persisted cookie with area defined:</b><br/>");
c = new Cookie("Login","_yang");
c.setMaxAge(3*24*60*60);
c.setDomain("some.com");
response.addCookie(c);
out.println("Name: "+c.getName()+"<br/>");
out.println("Value: "+c.getValue()+"<br/>");
out.println("Domain: "+c.getDomain()+"<br/>");
out.println("Path: "+c.getPath()+"<br/>");
out.println("MaxAge: "+c.getMaxAge()+"<br/>");
out.println("Version: "+c.getVersion()+"<br/>");
]]></jsp:scriptlet>
</p>
</body></html>
</jsp:root>
Now install CookieDump.jsp in bobcat absence appliance directory. Then run HttpRequestGet.java:
>java HttpRequestGet /CookieDump.jsp 8080
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=B63F49ABFD8DF8A5DF0FDBCC92E317B9; Path=/
Set-Cookie: Language=English
Set-Cookie: User=" Yang"; Expires=(timestamp)
Set-Cookie: Password=top_secret; Domain=some.com
Set-Cookie: Login=_yang; Domain=some.com; Expires=(timestamp)
Content-Type: text/html;charset=UTF-8
Content-Length: 677
Date: (timestamp)
Connection: close
<html><body><p><b>Temporary cookie:</b><br/>
Name: Language<br/>
Value: English<br/>
Domain: null<br/>
Path: null<br/>
MaxAge: -1<br/>
Version: 0<br/>
<b>Persisted cookie:</b><br/>
Name: User<br/>
Value: Yang<br/>
Domain: null<br/>
Path: null<br/>
MaxAge: 259200<br/>
Version: 0<br/>
<b>Temporary cookie with area defined:</b><br/>
Name: Password<br/>
Value: top_secret<br/>
Domain: some.com<br/>
Path: null<br/>
MaxAge: -1<br/>
Version: 0<br/>
<b>Persisted cookie with area defined:</b><br/>
Name: Login<br/>
Value: _yang<br/>
Domain: some.com<br/>
Path: null<br/>
MaxAge: 259200<br/>
Version: 0<br/>
</p></body></html>
As you can see, there 5 accolade included in the HTTP acknowledgment attack section. The first one is
added by the JSP server. The additional 4 are added by my JSP page.
Conclusion
- Cookie is a section of advice the server is allurement applicant the canyon it aback on the next request.
- Cookie is best way to hotlink assorted requests into a "session".
- Cookies are about safe to accept.
- Persistent accolade are stored as files on applicant system.
- Cookies are anesthetized in HTTP appeal and acknowledgment attack section.
- Setting and accepting accolade are simple to do in JSP pages.
|
println, cookie, domain, version, cookies, maxage, value, response, persisted, temporary, null<, setting, defined, getversion, getmaxage, getpath, addcookie, getname, getvalue, cookiedump, getdomain, timestamp, , temporary cookie, cookie with, < jsp, persisted cookie, cookie <, getversion <, getmaxage <, getpath <, println maxage, println version, defined <, version 0<, cookies are, path null<, domain some, println path, domain defined, println domain, println <, new cookie, < body, html <, cookiedump jsp, getdomain <, response addcookie, getvalue <, println name, println value, getname <, jsp page, < html, cookie with domain, persisted cookie with, temporary cookie with, tutorials tutorial notes, cookie login yang, domain some com<, response header section, com response addcookie, tutorial notes using, jsp directive page, cookie user yang, jstl tutorials tutorial, cookie with specified, notes using cookies, |
Also see ...
Syntactic Elements of a JSP PageThere are two types of data in a JSP page:Template Data: The changeless part, annihilation that will be affected anon to the ac
i(Continued from antecedent part...)/iWhat happens actuality is that the server is apparently sending acknowledgment withcontent type set to text/xml. To fix the problem, we charge to use a directiveelemen
i(Continued from antecedent part...)/iJSP Archetype "CurrentTime.jsp"The afterward archetype has three JSP files alive calm to appearance you how to use "deca
i(Continued from antecedent part...)/iIt s actual absorbing to see the Servlet chic translated from CurrentTime.jsp: package org.apache.jsp;import javax.servlet.*;import javax.ser
This affiliate shows you:What are the requirements to upload files to Web servers.The RFC 1867 addendum of HTML for uploading files.How to address a HTML page
i(Continued from antecedent part...)/iHere is sample HTML page to appearance you how to use Book ascribe acreage and "multipart/form data" encryption type: <?xml version="1.0"?p
i(Continued from antecedent part...)/iOf course, I aswell wrote the UploadForm.jsp to present the book upload anatomy page basedthe settings: <?xml version="1.0"?<jsp:root
i(Continued from antecedent part...)/iUploadSave.jsp Extenuative Uploaded FilesAs you can see from the antecedent section, auctioning uploaded files aback to the br
i(Continued from antecedent part...)/iOn UploadForm page, I called the aforementioned files: File Upload Form:Your email: [_yang@yahoo.com ] Your comments: [I am uploadi
What is JSP?JSP is a technology, not a language. It allows Web page authors to put activating datainto a Web certificate with Java statements anchored in appropriate HTML tag