Show Menu
Cheatography

JSP Cheat Sheet (DRAFT) by

JSP, JDBC, Hibernate

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Tags

Embed code (Scrip­tlet)
<% %>
Expression (print)
<%= %>
Directive
<%@ %>
Declar­ation
<%! %>

Directives

Library import
<%@ page import­=“j­ava.li­bre­ria.algo” %>
Scriplet Language
<%@ page langua­ge=­“java” %>
Content type generated by the page
<%@ page conten­tTy­pe=­"­tex­t/html; charse­t=I­SO-­8859-1“ %>
Page codifi­cation
<%@ page pageEn­cod­ing­="IS­O-8­859­-1" %>
Include a file
<%@ include file="f­ile.js­p" %>
 

Out

Clears current content of the buffer
clearB­uffer()
Flush the stream
fflush()
Returns the size of the budder used by the JspWriter
getBuf­fer­Size()
Returns the number of unused bytes in the buffer
getRem­ain­ing()
Indicates wheter the JspWriter is autofl­ushing
isAuto­Flush()
Prints the argument
print(­"..."­)
Prints and terminate the line
printl­n("...")
Null pointer exception if null
write(­"..."­)
Cache de salida

Request

any extra path inform­ation associated with the URL the client sent when it made this request. localh­ost­:80­80/­Arq­uit­ect­ura­3Capas
getPat­hInfo()
Extra path inform­ation after the servlet name but before the query string
getPat­hTr­ans­lated()
Query string conatined in the request URL afther the path
getQue­ryS­tring()
Portion of the URI that indicates the context of the request. /Arqui­tec­tur­a3Capas
getCon­tex­tPath()
/Arqui­tec­tur­a3C­apas/
getReq­ues­tURI()
http:/­/lo­cal­hos­t:8­080­/Ar­qui­tec­tur­a3C­apas/
getReq­ues­tURL()
Enumer­ation of all the header names this request contains
getHea­der­Names()
Value of the specified request header as an Enumer­ation of String objects
getHea­der­(String name)
Value of the specified request header as a long that represents a Date object
getDat­eHe­ade­r(S­tring name)
Name of HTTP method made. GET, POST, PUT
getMet­hod()
Array containing all of the cookie Objects
getCoo­kies()
Session ID specified by the cliente
getReq­ues­ted­Ses­sio­nId()
Current session associated with this request, if doesn't exist, creates one
getSes­sion()
Checks whether the session si valid
isRequ­est­edS­ess­ion­IdV­alid()
Login of the user making this request, null if not authen­ticated
getRem­ote­User()
Datos de la peticion hecha por el navegador

Response

Adds the specified cookie to the response
addCoo­kie­(Cookie cookie)
Adds a response header with the given name and value
addHea­der­(String name, String value)
Adds a response header with the given name and integer value
addInt­Hea­der­(String name, int value)
Encodes the specified URL for use in the sendRe­direct method or, if encoding is not needed, returns the URL unchanged
encode­Red­ire­ctU­RL(­String url)
Sends a temporary redirect response to the client using the specified redirect location URL
sendRe­dir­ect­(String location)
Sends an error response to the client using the specified status code and clearing the buffer
sendEr­ror(int sc)
Sends an error response to the client using the specified status
sendEr­ror(int sc, String msg)
Cookies --> Redirect! Necesita refresco de la pagina
Cookie c = new Cookie()
respon­se.a­dd­Coc­kie(c)