0% found this document useful (0 votes)
4 views2 pages

Process JSP

The document is a JSP script that calculates the Body Mass Index (BMI) based on user-provided height and weight. It categorizes the BMI into four statuses: Underweight, Normal, Overweight, and Obese, providing corresponding advice for each category. The resulting BMI, status, and advice are displayed in a styled HTML format.

Uploaded by

2023218308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Process JSP

The document is a JSP script that calculates the Body Mass Index (BMI) based on user-provided height and weight. It categorizes the BMI into four statuses: Underweight, Normal, Overweight, and Obese, providing corresponding advice for each category. The resulting BMI, status, and advice are displayed in a styled HTML format.

Uploaded by

2023218308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

process.

jsp Thursday, 15 May 2025, 9:47 am

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


2 <%
3 String name = request.getParameter("name");
4 int age = Integer.parseInt(request.getParameter("age"));
5 double height = Double.parseDouble(request.getParameter("height"));
6 double weight = Double.parseDouble(request.getParameter("weight"));
7
8 double bmi = weight / (height * height);
9 String status = "";
10 String advice = "";
11 String color = "";
12
13 if (bmi <= 18.4) {
14 status = "Underweight";
15 advice = "Consider a nutritious diet to gain healthy weight.";
16 color = "#ffe599";
17 } else if (bmi >= 18.5 && bmi <= 24.9) {
18 status = "Normal";
19 advice = "Great job! Maintain your healthy lifestyle.";
20 color = "#b6d7a8";
21 } else if (bmi >= 25.0 && bmi <= 39.9) {
22 status = "Overweight";
23 advice = "Try regular exercise and a balanced diet.";
24 color = "#f9cb9c";
25 } else if (bmi >= 40.0) {
26 status = "Obese";
27 advice = "Consult a healthcare provider for personalized advice.";
28 color = "#ea9999";
29 }
30 %>
31 <!DOCTYPE html>
32 <html>
33 <head>
34 <meta charset="UTF-8">
35 <title>BMI RESULT</title>
36 <style>
37 body {
38 font-family: Arial, sans-serif;
39 background: #f5f5f5;
40 display: flex;
41 justify-content: center;
42 align-items: flex-start;
43 min-height: 100vh;
44 }
45 .result-container {
46 background: #fff;
47 padding: 30px 40px;
48 border-radius: 10px;
49 box-shadow: 0 4px 12px rgba(0,0,0,0.1);
50 margin-top: 40px;
51 width: 400px;
52 }
53 h2, h3 {
54 text-align: center;
55 }
56 table {
57 width: 100%;

Page 1
process.jsp Thursday, 15 May 2025, 9:47 am

58 border-collapse: collapse;
59 margin: 16px 0;
60 }
61 th, td {
62 border: 1px solid #ccc;
63 padding: 8px 12px;
64 text-align: center;
65 }
66 th { background: #eee; }
67 </style>
68 </head>
69 <body>
70 <div class="result-container">
71 <h2>BMI CALCULATION RESULT</h2>
72 <h3>Inserted Information:</h3>
73 <ul>
74 <li><b>Name:</b> <%= name %></li>
75 <li><b>Age:</b> <%= age %></li>
76 <li><b>Height:</b> <%= height %> meters</li>
77 <li><b>Weight:</b> <%= weight %> kg</li>
78 </ul>
79 <h3>BMI Value and Status:</h3>
80 <table>
81 <tr>
82 <th>BMI</th>
83 <th>Status</th>
84 </tr>
85 <tr style="background:<%= color %>;">
86 <td><b><%= String.format("%.2f", bmi) %></b></td>
87 <td><b><%= status %></b></td>
88 </tr>
89 </table>
90 <h3>Advice:</h3>
91 <p><%= advice %></p>
92 <hr>
93 </div>
94 </body>
95 </html>
96

Page 2

You might also like