I have a small web app and sometimes when I display a query, I get rows that are duplicated. However when I run the same query on my DB i do not get anything duplicated, does anybody konw why is this happening...
this is my code in my .jsp page
This is what i get when i run my query on my DB. (2.JPG)
This is the output in my browser (1.JPG)...as you can see, the rows inside the red rectangle are the extra ones.
Okay. And as I suggested, we should be looking at the code which processes that query and produces the ResultSet, not the code you posted.
Eduardo Ponce de Leon
Joined: May 13, 2009
I found my error. if you take a look at the code in my .jsp the problem is from the colums i am getting the value of the row. both of them are from column 1 instead of 1 & 2. Also the name of the colums are differente..
this is the correct string for my query in my .jsp file
"SELECT * FROM public.\""+provList[i]+"_"+request.getParameter("yrOption")+"\" WHERE \"Cuenta\" = '"+R3.getString(2)+"' AND \"Subcuenta\" = '"+R3.getString(1)+"';"
That's a strange question. Your code is already Java. So your question sounds as if you think the only way to run Java code is by embedding it in a JSP.
But obviously that isn't the case. The professional way to implement those requirements would be to write a servlet which extracts the data from the ResultSet and puts it
into a list of some kind of object which represents a row in your output. Add that list to the request as a request attribute and forward to a JSP which simply copies the data
from the list to the output HTML.
I did like to join the recent discussion on excluding scriptlets from JSP for alternate ways -
I do agree with the trouble with code readability and maintenance on using java code in JSP.
1) But I am thinking which of the approaches has better performance - though including every thing in one JSP file has the issue above mentioned - is not it faster at performance than a layer code which has to go through various classes to get the same job done.
2) also i found few constraints where alternate way like the JSTL tag libraries or Struts libraries are still not well versatile to meet every real world requirement -
ex: i did not find a way to iterate a collection of collection in either JSTL (c:foreach) or Struts(logic:iterate) libraries recursively. Both c:foreach and logic:iterate can extract values in list but not from a list of list.
Any though you would like to put on this problem with out using srciplets.