![]() |
Processing form's element(s) in JSP
I have a HTML form in JSP page, and in the <header> I have a JavaScript validation. The user must enter one field: name or id or year, and a java file will search the student in database by name or by id or by year. The JavaScript alerts when no field is filled and performs the **action** if one field is filled.
Code:
<html><head>.....</head>The problem is I want to process the parameter which I receive in FoundStudents.jsp: If I get the year, I look in DB which student(s) are in that year and display all that student(s)' data(do that in a java file). How could I do that in FoundStudents.Jsp without checking again which field is filled(I've done that in JavaScript from **SearchStudent.jsp**). I mean the FoundStudents.jsp calls a method in the java file for searching and displaying. I tried by now with the **input hidden** that worked, but that is for more forms. I have only 1. **FoundStudent.jsp** Code:
<%@page import="stud.diploma.students.StudentsManager"%>It searched by name and by year only. Didn't search by ID (I had exception here ` Code:
<td><%= search.getId()%></td>Lines like : search = StudentsManager.getInstance().studByName(name); **Search** is a Student type object. (Object Student is creaded in a java file) **StudentsManager** is a java class that receives calls to it's methods from JSP. getInstance() creates an instance of StudentsManager. Method **studByName(name)** receives the parameter **name** from the form and searches it in the database. |
I changed the (java)script to:
Code:
<script language="javascript">Code:
if((request.getParameter("year") != null)||(request.getParameter("name") != null)){ |
| All times are GMT +1. The time now is 10:08 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.