Fork me on GitHub Fork me on GitHub

request


<%
    print("<html><body>");
    print("Method : " + request.getMethod() + "<br/>");
    print("Protocol : " + request.getProtocol() + "<br/>");
    print("User-Agent : " + request.getHeader("User-Agent"));
    print("</body></html>");
%>

Overview

Object that provides the properties and functions of HTTP Request


Operations

Operation Returns Description
getMethod()String
request.getMethod()
Returns the HTTP method of the request
getProtocol()String
request.getProtocol()
Returns the protocol of the request
getQueryString()String
request.getQueryString()
Returns the query String of the request
getContent()String | Object
request.getContent()

Returns the content of the request.

If the request content type is either application/json or application/json/badgerfish, then content is returned as an object. Otherwise, it is returned as a String.

getContentType()String
request.getContentType()
Returns the content Type of the request
getContentLength()Number
request.getContentLength()
Returns the content length of the request
getRequestURI()String
request.getRequestURI()
Returns the part of this request's URL from the protocol name up to the query String in the first line of the HTTP request
getRequestURL()String
request.getRequestURL()
Reconstructs the URL the client used to make the request
getPathTranslated()Object
request.getPathTranslated()
Returns any extra path information before the query String, and translates it to a real path. If the URL does not have any extra path information, this method returns null.

isSecure()Boolean
request.isSecure()
Returns a Boolean indicating whether this request was made using a secure channel, such as HTTPS.
getRemoteAddr()String
request.getRemoteAddr()
Returns the Internet Protocol (IP) address of the client that sent the request.
getContextPath()String
request.getContextPath()
Returns the portion of the request URI that indicates the context of the request
getLocalPort()Number
request.getLocalPort()
Returns the request local port number
getUser()String
request.getUser()
Returns the name of the current authenticated user.
getInputStream()Stream
request.getInputStream()
Retrieves the body of the request as binary data.
getHeader(headerName) String
request.getHeader("User-Agent")
Returns the Header properties
getAllHeaders() Object
request.getAllHeaders()
Returns all request headers as an object.

{ "Content-Type": "application/json", "User-Agent": "Mozilla/5.0", "Cookie": "JSESSIONID=4DA02FE19BA086964227"
}
getParameter(paramname [,charset]) String
request.getParameter("action")
Returns the request parameter. For multipart/form-data requests, an optional charset parameter can be passed to get the encoded value.
getAllParameters([charset]) Object
request.getAllParameters("UTF-8")
Returns all request parameters as an object. For multipart/form-data requests, an optional charset parameter can be passed to get the encoded values.
getLocale() String
request.getLocale()
Returns the preferred Locale that the client will accept content in, based on the Accept-Language header.
getAllLocales() Object
request.getAllLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale,If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.
getMappedPath() Object
getMappedPath()
If file is mapped and request came through mapping.getMappedPathURL() will return file. If file is not mapped It will return null.
getFile(formFeildName)File
request.getFile("fieldName")
Returns a file object when the content type is multipart/form-data

var file = request.getFile("userfile");
file.saveAs(file.getName());
getAllFiles()Object
request.getAllFiles()
Returns an object of files when the content type is multipart/form-data

var files = request.getAllFiles();
for(var name in files) { if(files.hasOwnProperty(file)) { var file = files[name]; file.saveAs(name); }
}
getCookie(name)String
request.getCookie(name)

Returns a cookie object.

{ 
	"name": "user",
	"value": "ruchira",
	"domain": "jaggeryjs.org", 
	"maxAge": 100000, 
	"secure": true, 
	"path": "/", 
	"comment": "Authenticated user"
}
getAllCookies()Object
request.getAllCookies()

Returns an object with cookies.

{ 
	"user" : { "name": "user", ..... }, 
	"remember" : { "name": "remember", ..... }
}