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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Using tag of Core JSTL tags 
 

In this example we have used Core JSTL tag that is used to redirect the page to given url, here param is used to get parameter from request.

 

Using tag <c:redirect> of Core JSTL tags

                         

In this example we have used Core JSTL tag <c:redirect> that is used to redirect the page to given url, here param is used to get parameter from request. Tag <c:forEach> is member of Core tag library of JSTL so before using Core JSTL tags we must include following line of code :-

      <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

 

 

 

redirect_CoreJstl.jsp

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
    <title>Import a Page</title>
</head>
<body><frame name="frame1">
        <form method="POST">
            <p>Enter 1 for http://www.roseindia.net<br>
            Enter 2 for http://www.google.com<br>
            Enter 3 for http://www.yahoo.com<br>
            Enter 4 for http://www.msn.com<br>
            <table >
            <tr>
                <td>Enter Your Choice </td>
                <td>
                    <input type="text" name="choice" size="20"/>
                </td>
                <td><input type="submit" value="submit"/></td>
            </tr> 
    </form></frame>
    <c:if test="${pageContext.request.method=='POST'}">
        <c:choose>
            <c:when test="${param.choice=='1'}">
                <c:redirect url="http://www.roseindia.net"/>
            </c:when>
            <c:when test="${param.choice=='2'}">
                <c:redirect url="http://www.google.com"/>
            </c:when>
            <c:when test="${param.choice=='3'}">
                <c:redirect url="http://www.yahoo.com"/>
            </c:when>
            <c:when test="${param.choice=='4'}">
                <c:redirect url="http://www.msn.com"/>
            </c:when>
            <c:otherwise>
                <font color="red"><b>Found wrong choice, try again...</font></b>
            </c:otherwise>
        </c:choose>
    </c:if>
</body>
</html>

Steps to run this example :

1:  Download the zip file of code and unzip this file, you will get a folder named  'redirect_page_jstlCoreTag'.
2:  Paste this folder in 'Apache Tomcat 6.0.16-->webapps' or generally in directory 'C:\apache-tomcat-6.0.16\webapps'.
3:  Start tomcat server by click on startup.bat file in 'C:\apache-tomcat-6.0.16\bin'.
4: Open browser and type url 'http://localhost:8080/redirect_page_jstlCoreTag/redirect_CoreJstl.jsp' or click on this link.

When program will run in browser this will show the following output.....

when user will fill in the text box and click on submit button, next response will be according to the user choice, if user fills choice other than provided in the list, response will be the error message........

Download Source Code

                         

» View all related tutorials
Related Tags: c xml library file files stl orm ant form io user sed jstl tag parameter transform this js for add

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 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

What about instead of redirecting to .html redirection to .action

Posted by Greg on Wednesday, 09.17.08 @ 21:28pm | #80126

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
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.