hide and show result in jsp

hide and show result in jsp

what codes do i have to change to make my result display if only i enter the correct value? suppose if i click search,then the result will be display at the bottom.. if not.. only the header will be shown. i suppose to put an if statement,but im not sure where to put it. before or after my while statement in search.jsp file. please help. thank you so much.

this is my viewsearch.jsp file

<%-- 
    Document   : VIEW 
    Created on : Jun 9, 2012, 11:20:18 PM
    Author     : Asus
--%>

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


<%@ page language ="java" import="java.sql.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%

Class.forName("oracle.jdbc.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "health", "health");

String value= request.getParameter("bmi_value");
%>

<%
double value1= Double.parseDouble(request.getParameter("bmi_value"));
%>

<%
String SQLupdate = "SELECT MEMBER_ID,BMI_VALUE FROM BMI WHERE BMI_VALUE =value1";
PreparedStatement st = con.prepareStatement(SQLupdate);                    

Statement statement = con.createStatement();
%>
<%
if (value1 < 18.5)
{
    statement.executeQuery("SELECT M.MEMBER_ID, M.FNAME,M.LNAME,M.AGE,B.HEIGHT,B.WEIGHT FROM BMI B, MEMBER M WHERE M.MEMBER_ID= B.MEMBER_ID");
}

else
      if (value1>=18.5 && value1<=25.0)
           {
    statement.executeQuery("SELECT M.MEMBER_ID, M.FNAME,M.LNAME,M.AGE,B.HEIGHT,B.WEIGHT FROM BMI B, MEMBER M WHERE M.MEMBER_ID= B.MEMBER_ID");
      }

if (value1 > 25.0)
 {
    statement.executeQuery("SELECT M.MEMBER_ID, M.FNAME,M.LNAME,M.AGE,B.HEIGHT,B.WEIGHT FROM BMI B, MEMBER M WHERE M.MEMBER_ID= B.MEMBER_ID");
}
%>
<script language="javascript">
alert("Successfully Searching.");
window.location.href = "viewSearch2.jsp";
</script>


and this is my search.jsp file

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

<%@page import="java.sql.*"%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Healthy Preggers</title>
<meta name="keywords" content="css templates, healthy living, diet, nutrition, fitness, web design" />
<meta name="description" content="Healthy Living - free CSS template provided by templatemo.com" />
<link href="css/templatemo_style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
    color: #999999
}
.style2 {color: #BF3E3E}
-->
</style>
</head>
<body>
<%@include file = "header.jsp" %>
<%@include file = "menu.jsp" %>


<%   Class.forName("oracle.jdbc.OracleDriver");
     Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "health", "health"); 
       %> 
<body>

<html>
<head>
</head>
<body>
<br><br><br><br><br><br>
<form method="post" name="form1" action="viewsearch.jsp">
<table border="1" width="300" align="center" bgcolor="FFA3B3">
<tr><td colspan=2 style="font-size:12pt;color:#00000;" align="center">
<h3>Enter BMI Value</h3></td></tr>
<tr><td ><b>Enter BMI </b></td>
<td>: <input  type="text" name="bmi_value" id="BMI_VALUE">
</td></tr>

<tr><td colspan=2 align="center">
<input  type="submit" name="submit" value="Search">  
     <input type="reset" value="Reset" name="Reset" /></td></tr>
</table>
</form>
<h1 align="left">VIEW SEARCH</h1>

<%
 Statement st=con.createStatement();
  ResultSet rs3=st.executeQuery("SELECT M.MEMBER_ID, M.FNAME,M.LNAME,M.AGE,B.HEIGHT,B.WEIGHT, B.BMI_VALUE FROM MEMBER M , BMI B   WHERE M.MEMBER_ID=B.MEMBER_ID");
 %>
<table  align="center"  border="1">

<tr  bgcolor="ACFA58"> 
    <th class="listingContent" witdth="10">No</th>
   <th class="listingContent" width="100">ID</th>
   <th class="listingContent" width="1000">FIRST NAME</th>
   <th class="listingContent" width="1000">LASTNAME</th>
   <th class="listingContent" width="1000">AGE</th>
   <th class="listingContent" width="1000">HEIGHT</th>
   <th class="listingContent" width="1000">WEIGHT</th>
   <th class="listingContent" width="300">BMI VALUE</th>

 </tr>
  <%
  int y= 1;
  while(rs3.next())
{ %>


<tr bgcolor="D0F5A9"  style="visibility:hidden" onclick="form1">
<td class="listingContent" align="center"><%= y%></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("member_id") %></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("fname") %></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("lname")%></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("age")%></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("height")%></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("weight")%></td>
<td class="listingContent" width="10" align="center"><%= rs3.getString("bmi_value")%></td>
  </tr>** 

  <% 
 y++;
 }%>
  </table>


</body>
</html>

</table>
</form>
</body>
</html>
<br><br><br>

<div id="templatemo_footer">
    Copyright © 2012| 
    Designed by:Fara Zati Aina</a> | 
    For: CSC 444</div> 
</center></body>
</html>
View Answers









Related Tutorials/Questions & Answers:
hide and show result in jsp
hide and show result in jsp  what codes do i have to change to make my result display if only i enter the correct value? suppose if i click search,then the result will be display at the bottom.. if not.. only the header
JSP hide and show tables
JSP hide and show tables In this tutorial, you will learn how to hide and show html tables using javascript in jsp. Here is an example of simple jsp code which is having a table consists of database data and a Go button. Using
Advertisements
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
Help with jQuery show hide div script - JSP-Interview Questions
Help with jQuery show hide div script  Hi guys, I have a jquery script for showing and hiding the content inside, between two divs, controlled with radiobuttons. I like to use the same jquery script for another group of divs
Hide the Jsp Page
Hide the Jsp Page  I want to hide the Entire JSP Page.is it possible
Show Hide Text Javascript - Java Beginners
Show Hide Text Javascript  Please tell me how to show hide text using Java Script
JavaScript Show Hide table
JavaScript Show Hide table...; In this section, we are going to show and hide table on clicking the button using...;html> <h2>Show or Hide table in JavaScript</h2> <
Jquery Hide and Show Div
Using jQuery effects one can perform lots of task such as Hide, Show, Toggle... and Hide methods in Java. .show() in jQuery is used to display the matched elements... that illustrates how to can hide and show HTML elements with the hide() and show
show, hide, disable components on a page with struts - Struts
show, hide, disable components on a page with struts  disabling a textbox in struts.. in HTML its like disable="true/false" how can we do it in struts
Hide show HTML forms using javascript
Hide show HTML forms using javascript  How to hide a HTML form in my application using JavaScript?   HTML Code to create checkbox <...;div id="yourDiv"> ...other forms... </div> JavaScript function to hide
hide division - JSP-Servlet
hide division  On click Hide one dividion and visible another division...   Hi Friend, Try the following code: function showhide() { document.getElementById('div2').style.visibility = 'visible
Hide/Show paragraph by button click
Hide/Show paragraph by button click In this tutorial, we will discuss about how to hide/show paragraph by clicking on button using jQuery. In the below... to show Paragraph</button> <p>This will Hide after clicking button<
Toggle hide/show by clicking same button
Toggle hide/show by clicking same button In this tutorial, we will discuss about how to toggle hide/show by clicking button. In the given below 2 example, there is button ,by clicking on it, the paragraph will hide/show . In first
how can i hide and show tables
how can i hide and show tables  hai, i am creating a form which the code is included below i want to hide the tables initially and after i click go...;/html>   You can use javascript. Here is an example of simple jsp code
Dojo Show and Hide Dialog
Dojo Show and Hide Dialog         In this example, you will learn dojo show and hide... box. Try Online: Show and Hide DialogADS_TO_REPLACE_1 Here
Write a C/C++ program to show the result of a stored procedure
Write a C/C++ program to show the result of a stored procedure   how to write this?? Write a C/C++ program to show the result of a stored procedure "PROCRESETMAIL" on database "USER_NOTIFY
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my code part:- PAYMENT DETAILS <table cellpadding="0" cellspacing="0" align...; <jsp:include page="calendar_1.html" /> </td>
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Jsp not display desired result - JSP-Servlet
Jsp not display desired result  Hello all, I want to be able to display picture from Ms Sql 2000 using JSP. Below is the code I used but does... friend, For solving the problem visit to : http://www.roseindia.net/jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
How to show database values into graph using jsp?
How to show database values into graph using jsp?  How to show database values into graph using jsp
combox value are not show in a JSP - JSP-Servlet
combox value are not show in a JSP  i have a combo box in a JSP after submit it does not show its value in logic.jsp Home.jsp: <... show null. please let me how i can find the value of combo box on logic.jsp.
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying... status - 404. How can i resolve it in JSP
Hide text by clicking button
Hide text by clicking button In this tutorial, we will discuss about hide/show... : hide and show .The "hide " button is used to hide text and "show button " is used to show text. These actions are fired when "
retrive the result of a serach string from other sites - JSP-Servlet
retrive the result of a serach string from other sites  Sir, suppose i have create my own websites, and i want to search an item in my sites and as well as from other search sites and i want to show all the search result in my
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
javascript hide element
javascript hide element  How can we hide / show HTML elements using JavaScript
Show text by button click using jQuery
Show text by button click using jQuery In this tutorial, we will discuss about hide/show text by clicking on button. In the below example, there are two buttons : hide and show .The "hide " button is used to hide text
hide url
hide url  how i can hide url i have lot of jsp pages when i call one jsp in address another jsp page name also displayed in the address bar? url not visible to endusers please tell me any answer what i should do
how to forward select query result to jsp page using struts action class
how to forward select query result to jsp page using struts action class  how to forward select query result to jsp page using struts action class
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
show folder on server by clicking a row in table using jsp and ajax
show folder on server by clicking a row in table using jsp and ajax  Hi, i want a jsp page which has one dropdown and one textfield. when i click on serach button after selecting the dropdown and a value in textfield it should
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status" I am thinking to use a map of seats ( with pictures controllers as seats) What
hide the url in address bar
hide the url in address bar  how i can hide url in address bar????? i have lot of jsp pages when i call one jsp in address another jsp page name also... will enter the username and password in the addressbar the answer jsp will come .jsp
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... increasin 1 in the previously stored tsk id) on JSP page when I click
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... increasin 1 in the previously stored tsk id) on JSP page when I click
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I... increasin 1 in the previously stored tsk id) on JSP page when I click
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers on JSP
Hide/show Image by click
Hide/show Image by click In this tutorial ,we will discuss about how... are given. By clicking on upper line , it will hide the image and the line...; Click here to hide the logo </font> </div> <div id
Adding image to database through jsp or HTML page ,while adding only image should show.
Adding image to database through jsp or HTML page ,while adding only image should show.   Adding image to database through jsp or HTML page,while adding only image should show. After that i need view that uploaded image from
Dynamically hide textbox
Dynamically hide textbox  I have a drop down(combo box) with 2 values (reference and file).When refrence is selected from the drop down.... AVOID PAGE REDIRECTING jsp+servlet+oracle+javascript I am using
ModuleNotFoundError: No module named 'hide'
ModuleNotFoundError: No module named 'hide'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hide' How to remove the ModuleNotFoundError: No module named 'hide' error
JavaScript hide() method
JavaScript hide() method       JavaScript provides a method hide(), so that user can hide elements whenever they require. This function may be helpful when user wants to show some
JavaScript hide image
; In this section, we are going to show and hide image on clicking the button using...;h2>Show and Hide Image in JavaScript</h2> <script language... JavaScript hide image
to show graph
to show graph  by clicking on submit button how to show the graph by fetching data in mysql?   Please visit the following link: JSP graph by fetching data in mysql
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> Insert title here h3

Ads