Share on Google+Share on Google+

Conditional Forward using EL

We can forward one page to another jsp page, html page or any other servlet page.

Conditional Forward using EL


We can forward one page to another jsp page, html page or any other servlet page. A condition is checked before forwarding the page to another page. 

In this example we are using two pages to fulfill this condition.

  1. ConditionalForwardUsingEL.html
  2. ConditionalForwardUsingEL.jsp

    In the first page we are making a html form in which the user will enter his name and the password to enter into the page.
    In the second page we are retrieving the values from the html page which we have have passed in the html page. In this jsp page we are checking the condition if the "username" is equal to null then the page will be forwarded back to the html page.

The code of the program is given below:


<title>This is Conditional Forward using EL</title>
<form method = "get" action = "ConditionalForwardUsingEL.jsp">
    <b>Enter your name
  	 :<i nput type = "text" name = "username" ><b><br>
    <b>Enter the password
       : <input type = "password" name = "pwd" ><b><br>
  <input type 
       = "submit" name = "submit" value = "submit"><b><br>


		<title>Conditional Forward By using EL</title>
		  if(request.getParameter("username")==null || 
     <jsp:forward page = "ConditionalForwardUsingEL.html"/>
		   Hello : ${param.username} ! How are you.

The output of the program is given below:

When the name is null:

When we entered the values:

The output will be:

Download this example.



Posted on: February 11, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: Conditional Forward using EL  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image