Home Jsp getRequestURI() Method Of The Request Object
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

getRequestURI() Method Of The Request Object

Advertisement
This section gives you the detailed explanation of the getRequestURI() method of the request object in JSP.

getRequestURI() Method Of The Request Object

     

This section gives you the detailed explanation of the getRequestURI() method of the request object in JSP. This method is used for getting the information of the URI of the current page of your JSP application. This method returns the URI of the current page from the URL (Unified Resource Locator). The retrieved URI is the string which is mentioned in the URL after the host name up to the current page. The retrieved URI does not contain the host name or any parameter mentioned from the query string after the page name in the URL.

This section also provides an example of JSP with the complete code which gives you the URI of the current page. You can directly put the code in your JSP application for getting URI as per requirement.

Here is the code of the GetRequestURIMethod.html file:

<html>
	<body>
		<form action="GetRequestURIMethod.jsp" method="get">
			<table border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>User Name: </td>
					<td><input type="text" size="20" name=
"txtUserName" />
				</tr>
				<tr>
					<td>Password: </td>
					<td><input type="password" size="20" 
name="txtPassword" />
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td><input type="submit" value="Submit"
 name="B1" /></td>
				</tr>
			</table>
		</form>
	</body>
</html>

Output for the GetRequestURIMethod.html file:

Here is the JSP code of the GetRequestURIMehtod.jsp file:

<%
	out.println("<b>" + request.getRequestURI() + "</b>");
%>

Output for the above mentioned JSP file:

Download the HTML file.

Download the JSP file.

Advertisements

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 9, 2008

Ask Questions?    Discuss: getRequestURI() Method Of The Request Object  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com