JSP page with if else conditions

467 views Asked by At

I have a jsp form page where created a dropdown field. Based on one of the value chosen I need to show the upload button option which is in different jsp. I tried the below code. Can someone please assist me what am missing here as the code is not showing any error and not working thou.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
...
<body>

    <div align="center" style="margin-top: 50px;">

        <form action="FirstwebServlet">
            Please enter username: <input type="text" name="username" size="20px"> <br>
            Please enter your password: <input type="text" name="password" size="20px"> <br>


               <br> Please select the option: 
               <select required="required" name="sel">
                 <option value="None">Choose from the list </option>
                 <option value="Report">Report</option>
                 <option value="Template">Template</option>


               </select> <br> 
              <% String sel = request.getParameter("sel");
   if( sel != null  && sel =="Template" ) {%>
       <%@ include file="upload.jsp" %> 

  <%  }
%>
            <input type="submit" value="submit">
        </form>

    </div>

</body>
</html>

I am not seeing any error for this code. But when I select the dropdown value it's not taking to upload field code.

0

There are 0 answers