File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Bug in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Bug in code" Watch "Bug in code" New topic

Bug in code

prathimaprasun rao
Ranch Hand

Joined: Jun 29, 2006
Posts: 55
hello everyone,
I have a jsp that has the following fields on the form:
1. studentid
All the above fields information is stored in "student" table.

Teacher assigns the value to performance field for each student.This field can have any one of the three values:
1. Poor

This form allows the user to add/edit student information in add/edit mode.
During add mode, the student record is created. If there is change in that students information, the teacher edits that record data during edit mode.
The principal can edit student information.
Now my goal is to disable the studentid field when the student performance changes from either poor/improving to good for the first time.When that performance field has good as value in it, then that studentid field needs to be disabled and the teacher will not be able to change the value in that field even if the value in that field changes from good to poor/improving. Only the principal should have the ability to change the value in that performance field during edit mode.

For that I have created a flag_code field in student table.My idea is when the flag_code field has N value for the first time, we should lock that field from changing to Y when we change the value in the performance field.

int status1=0, status2 =0;
int flagcount=0;
String flag="";
String iStr1 = "",iStr2="";


//Modified Code:-
strSQL=" select performance from "student" where upper(studentid)='"+studentid.toUpperCase()+"'";

Statement stmt12 = conn.createStatement();
ResultSet rs12 = stmt12.executeQuery(strSQL);
while ( {
status1 = rs12.getInt(1);

out.println("status code:"+status1);
//retrieving status value

iStr1 = String.valueOf (status1);

strSQL1 = "update student set flag_code ='N' where upper(studentid)='"+studentid.toUpperCase()+"'";
strSQL1 = "update student set flag_code ='Y' where upper(studentid)='"+studentid.toUpperCase()+"'";

out.println("flag_code for studentid = "+" " +" "+studentid + "is " + " " +strSQL1);
out.println("flag :"+flag);



if (mode.equals("add")||(mode.equals("edit") ||(flag.equals("1")&& (userProfile.equalsIgnoreCase("principal") ) ) )){

<input type="text" name="studentid" value="<%=studentid%>" SIZE="13" MAXLENGTH="13">
} else {
<input type="text" name="studentid" disabled value="<%=studentid%>" SIZE="13" MAXLENGTH="13">

The problem with my code is that I am unable to capture when the value changed to 3(good) either from 1 to 3 or 2 to 3.My code disabled the studentid field when the performance field has value 1 or 2 during edit mode before it changes to 3 for the first time.
The goal is:
The studentid field should be active during add mode.
The field should also be active in edit mode as long as the performance field value changes from 1 to 2 and vice versa.Once the performance field changes from 1 or 2 to 3 for the first time, the studentid field should be blocked even though the value changes from 3 to either 1 or 2 during edit mode. Could anyone let me know how to solve this issue?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and most people will just go elsewhere. Please read this for more information.

You can go back and change your post to add code tags by clicking the .

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Bug in code
It's not a secret anymore!