Example
Simple example
This small example provides an overview of the various methods and properties of the
request and response objects.
<%
response.setContentType("text/html")
%>
<H1>Request</H1>
<ul>
<li>request.requestURI = "<%= request.requestURI %>"</li>
<li>request.queryString = "<%= request.queryString %>"</li>
<li>request.servletPath = "<%= request.servletPath %>"</li>
<li>request.contextPath = "<%= request.contextPath %>"</li>
<li>request.pathInfo = "<%= request.pathInfo %>"</li>
<li>request.serverName = "<%= request.serverName %>"</li>
<li>request.serverPort = "<%= request.serverPort %>"</li>
<li>request.serverURL = "<%= request.serverURL %>"</li>
</ul>
<H1>Header</H1>
<ul>
<li>Host = <%= request.getHeader("host") %></li>
</ul>
<H1>Parameters</H1>
<%
var parameters = request.parameters
for(var p in parameters)
{
document.write(p + " - " + parameters[p] + "<br>")
}
%>
Redirection
<%
response.sendRedirect("http://adobe.com/")
%>