0

I want to create a jsp page such that i can calculate the grade for a paricular student

I have a jsp page where i can select the student name and enter the mark for subject wise .

eg:
<table>
<tr>
<td>Student name</td><td><select><option value="">Pooja</option><option value="">Rani</option></select>
<td>Subject <select><option value="" selected >Maths</select>
<td>Mark</td>
<td><input type="text ></td></tr>
<tr><td>Student name</td><td><select><option value="">Pooja</option><option value="">Rani</option></select>
<td>Subject <select><option value="" selected >English</option></select>
<td>Mark</td><td><input type="text ></td></tr>
</table>

Now how to create a logical condition such that if Pooja has 80 marks in english and 80 in maths , only then grade is B. I mean how to dynamically create an if condition. alos how to add a logical operator in front end

user2585622
  • 33
  • 1
  • 1
  • 9
  • You sure you want to do that inside the presentation layer (JSP?) Not maybe in the backend (Servlet?) after submitting your form? – Jan Dec 08 '15 at 11:04

2 Answers2

1

Use JSTL library.

<c:if test="${grade gt 80}">
    //your code here
</c:if>
Sanat Serikuly
  • 189
  • 3
  • 16
0

you can use conditional statements in jsp as follow:

<%@ page language="java" contentType="text/html;charset=UTF-8" %>

<html>

<head>
    <title>Java Code Geeks Snippets - Condition Content in JSP Page</title>
</head>

<body>

    <%
        if ("myvalue".equals(request.getParameter("myparam"))) {
    %>
        This will be printed if parameter myparam equals with myvalue
    <%
        } 
        else {
    %>
        This will be printed if parameter myparam DOES NOT equal with myvalue
    <%
        }
    %>

</body>
Haseeb Anser
  • 494
  • 1
  • 5
  • 19
  • I am going to add a condition dropdown like this . Now next to first condition i need to add a plus icon to add logical operators && || to check if both conditions are satisfied. how to do it pls help
    Student name Subject
    – user2585622 Dec 08 '15 at 10:50
  • are you getting your values from database? – Haseeb Anser Dec 08 '15 at 10:53
  • Only the student names i am getting from db. Condition operator i am hardcoding – user2585622 Dec 08 '15 at 11:05
  • get your db result in resulrset and aplly your if condition afterr getting value from the resultset – Haseeb Anser Dec 08 '15 at 11:19