Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 1304 | Replies: 11 | Solved
![]() |
•
•
Join Date: Jul 2008
Posts: 40
Reputation:
Rep Power: 0
Solved Threads: 0
I am facing problem while retrieving values from the jsp page.
my database structure is as follows:
-----------------------------------------------------------------------
m_emp_no|from_date|to_date|approver|status|
________________________________________
1002 | 22/9/2008 | 23/9/2008|1003 |pending
1004 | 29/9/2008 | 30/9/2008|1003 |pending
2044 | 15/9/2008 | 16/9/2008|3076 |pending
--------------------------------------------------------------------------
I am retrieving values from database properly using the following sql statement.
the username is stored in session which is the login id of the user.
I get two values for the approver 1003 and i am able to display that.I am using
But here i am getting only one value using the above code whereas i should get two values if i login with the id 1003.
Please provide a suggestion.
thanks in advance.
my database structure is as follows:
-----------------------------------------------------------------------
m_emp_no|from_date|to_date|approver|status|
________________________________________
1002 | 22/9/2008 | 23/9/2008|1003 |pending
1004 | 29/9/2008 | 30/9/2008|1003 |pending
2044 | 15/9/2008 | 16/9/2008|3076 |pending
--------------------------------------------------------------------------
I am retrieving values from database properly using the following sql statement.
the username is stored in session which is the login id of the user.
p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
ResultSet r=p.executeQuery();
while(r.next())
{
String id=r.getString("m_emp_no");<input type="text" name="id" value="<%=id%>" size="4">
but when i want to retrieve these values in a jsp i am using code:String id=request.getParameter("id");
so that i can update the rows in database for the status whether it is approved or cancelled.But here i am getting only one value using the above code whereas i should get two values if i login with the id 1003.
Please provide a suggestion.
thanks in advance.
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,704
Reputation:
Rep Power: 12
Solved Threads: 320
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
•
•
Join Date: Jul 2007
Location: Mumbai(Bombay), India
Posts: 363
Reputation:
Rep Power: 3
Solved Threads: 47
You **have not** pasted the code which is causing the problem or just displaying one record.
Right now I am just shooting in the dark here and assuming the problem lies in this piece of code, if it is inside the while loop :-
It is considered a bad practice to have multiple input elements (except radio buttons, check boxes) to be given the same name or ID.
Right now I am just shooting in the dark here and assuming the problem lies in this piece of code, if it is inside the while loop :-
html Syntax (Toggle Plain Text)
<input type="text" name="id" value="<%=id%> " size="4">
Last edited by stephen84s : Sep 26th, 2008 at 6:06 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
•
•
Join Date: Jul 2008
Posts: 40
Reputation:
Rep Power: 0
Solved Threads: 0
I was just trying with this code in a jsp because this text box is only to display
<input type="text" name="userid" value="<%=id%> " size="4"> instead of<input type="text" name="id" value="<%=id%>" size="4">
where i get both the values displayed but when i try to retrieve it using
request.getParameter("userid");
I dont get two values for the approver1003.
i have the db connection in servlet also, but even there it comes to the same problem.
please suggest what to do.
thanks
<input type="text" name="userid" value="<%=id%> " size="4"> instead of<input type="text" name="id" value="<%=id%>" size="4">
where i get both the values displayed but when i try to retrieve it using
request.getParameter("userid");
I dont get two values for the approver1003.
i have the db connection in servlet also, but even there it comes to the same problem.
please suggest what to do.
thanks
Last edited by shijunair : Sep 26th, 2008 at 6:19 am.
•
•
Join Date: Jul 2007
Location: Mumbai(Bombay), India
Posts: 363
Reputation:
Rep Power: 3
Solved Threads: 47
Try checking out request.getParameterValues() method, It should fetch you all the values even if some of the input elements have the same name.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
•
•
Join Date: Jul 2008
Posts: 40
Reputation:
Rep Power: 0
Solved Threads: 0
hi stephens,
what i have done now is that i have just modified my code .i have used a counter so that i get specific names for the values.
and i am retrieving it using
suppose i have one text box which gives me name=id1,id2,id3 and a list box which gives me name= ap1,ap2,ap3 ok.Here the above code gives me all the parameter names and values but i just need values for id1,id2,id3 so that using a single parameter and value name i can update the database.Is there any option where i can put an if and else condition such that the name starting with id only should be retrieved and the values for that .
please suggest.
thanks
what i have done now is that i have just modified my code .i have used a counter so that i get specific names for the values.
and i am retrieving it using
Enumeration parameterNames = request.getParameterNames();
while (parameterNames.hasMoreElements())
{
String parameterName = (String) parameterNames.nextElement();
String parameterValue = request.getParameter(parameterName);
System.out.println(parameterName+"has values"+parameterValue);
}suppose i have one text box which gives me name=id1,id2,id3 and a list box which gives me name= ap1,ap2,ap3 ok.Here the above code gives me all the parameter names and values but i just need values for id1,id2,id3 so that using a single parameter and value name i can update the database.Is there any option where i can put an if and else condition such that the name starting with id only should be retrieved and the values for that .
please suggest.
thanks
•
•
Join Date: Jul 2007
Location: Mumbai(Bombay), India
Posts: 363
Reputation:
Rep Power: 3
Solved Threads: 47
Well if the problem was solved then at least mention how it was solved, and mark the thread as solved so other people can use it.
Even previously I have noticed you just do not mention how a certain problem was solved, unless explicitly asked. Its not exactly fun to help such people.
Even previously I have noticed you just do not mention how a certain problem was solved, unless explicitly asked. Its not exactly fun to help such people.
Last edited by stephen84s : Sep 27th, 2008 at 2:50 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
•
•
Join Date: Jul 2008
Posts: 40
Reputation:
Rep Power: 0
Solved Threads: 0
hi stephens,
you are mistaken .the query is not yet solved and i dont know who has marked it as solved.
the very recent coding which i pasted was the coding which i tried it out so that i could get different name such as id1,id2,id3 etc and using enumeration i was retrieving all the values of parameter names.
I might have not framed the question properly because of which it is considered as solved.
Actually i have this code below where i want to update the database for different ids i.e id1,id2,id3 with the status such as approved or cancelled.I dont want to manually update again and again because i dont know when the person is going to apply for leaves.
I want to know what should be written above in the code which is given in bold because the many person apply for leaves and can be 'n' no of times in a year and the approver has to approve the leaves for that id which should be updated in database whether it is cancelled or approved. you can have a look at the database above .Is there any solution for this.
please suggest me.
thanks
you are mistaken .the query is not yet solved and i dont know who has marked it as solved.
the very recent coding which i pasted was the coding which i tried it out so that i could get different name such as id1,id2,id3 etc and using enumeration i was retrieving all the values of parameter names.
I might have not framed the question properly because of which it is considered as solved.
Actually i have this code below where i want to update the database for different ids i.e id1,id2,id3 with the status such as approved or cancelled.I dont want to manually update again and again because i dont know when the person is going to apply for leaves.
p=con.prepareStatement("select * from emp_leave_application where approver='"+username+"'");
ResultSet r=p.executeQuery();
while (r.next())
{
if(username!=null)
{
ps=con.prepareStatement("update emp_leave_application set status='"+approved1 or approved2 or approved3---n times+"' where approver='"+username+"' and m_emp_id='"+id1 or id2 or id3---n ids+"'");
ps.executeUpdate();
}
}please suggest me.
thanks
•
•
Join Date: Jul 2007
Location: Mumbai(Bombay), India
Posts: 363
Reputation:
Rep Power: 3
Solved Threads: 47
•
•
•
•
Added.......
retrieving values using the code on another jsp page.
thanks
From that anyone will assume the query was solved and one of the moderators might have marked it as solved.
Last edited by stephen84s : Sep 29th, 2008 at 6:34 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)






Linear Mode