Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
in JSTL 
 

In servlet when we want to use the session firstly it is important to get a session object either by creating it or by or by using the existing one. If the browser doesn't support the cookies then the container will automatically use the URL rewriting.

 

<c: url> in JSTL

                          

In servlet when we want to use the session firstly it is important to get a session object either by creating it or by or by using the existing one. If the browser doesn't support the cookies then the container will automatically use the URL rewriting. In servlets while the url rewriting we still have to tell the container to append the jsessionid in the end of the URL. 

We can do the same thing by using the <c: url> core action tag. By using the <c: url> we are doing the URL rewriting but by using the <c: param> core action tag inside the <c: url> our requirement for URL rewriting and URL encoding get fulfilled. 

In this example we are going to use <c: url> to construct a URL. Go through this example properly. 

The code of the program is given below:

 

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<html>
<head>
<title>Creating a URL</title>
</head>

<body>
<form method="POST">
<center>
<table border="1" >
<tr>
<td width="50%">Enter URL:</td>

<td width="50%">
<input type="text" name="url" value="http://www.roseindia.net"/>
</td>
</tr>

<tr>
<td width="50%">Enter your name</td>

<td width="50%">
<input type="text" name="name"/>
</td>
</tr>

<tr>
<td width="50%">Enter the password</td>

<td width="50%">
<input type="password" name="pwd"/>
</td>
</tr>

<tr>
<td width="50%">Enter your email address</td>

<td width="50%">
<input type="text" name="email"/>
</td>
</tr> 

<tr>
<td width="100%" colspan="2">
<p align="center">
<input type="submit" value="Submit" name="submit" />

<input type="reset" value="Reset" name="reset" />
</p>
</td>
</tr>
</table>
</center>
</form>

<c:if test="${pageContext.request.method=='POST'}">
<hr>
<c:url value="${param.url}" var="url">
<c:param name="name" value="${param.name}"/>
<c:param name="pwd" value="${param.pwd}"/>
<c:param name="email" value="${param.email}"/>
</c:url>
<br/><b>The resulting URL is:</b>
<c:out value="${url}"/>
</c:if>
<hr>
</body>
</html>

The output of the program is given below:

Download this example.

                          

» View all related tutorials
Related Tags: c stl orm text form parameters attributes io servlet initialization header format request headers parameter attribute context response ai tex

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.