This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I've been posting my problems here and I am glad it was answered.
I have another assignment. I am halway there, but the last bit is not working.
I have a servlet file which the code looks like this:
When I query, the result came out successfully in the command prompt (where the tomcat server started up and displayed) but in the viewSearch.jsp, there is no result displayed.
My viewSearch.jsp looks like this:
What's wrong? Is it because of my configuration of web.xml or these codes?
i dont know what is your requirement to display. i dont see any logic (setting values into List and Iterating it in jsp) in your code. Personally i recommend to use TO(Transfer Object)
What exactly happens when you hit the link to reach the 'Search' class. I mean do you get the viewSearch.jsp page displayed in the browser with the message No Record or do you end up seeing a blank page or some thing else?
thanks for replying. Maybe I didn't clearly explain my program. I have three files:
1)search.jsp (to enter search criteria),
2)search.java, (to connect to DB and query the DB) and
3)viewSearch.jsp (to display the search result).
When I enter a search criteria at search.jsp, it goes to search.java to find the
record in the database. I can see the search result in the command prompt
but in the viewSearch.jsp, stated "No Record Found" (I can see the table and all).
I can explain more if this is not enough. Really need some lights shed here.
Thanks in advance.
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Hi Karthick,
I see the logfile and no exception occured.
Hi Nishan,
I don't really understand what are your explanation. Please share with me your ideas
What i mean first of all you are using scriplet into your jsp page....which is not good for coding....
So, i mean use JSTL <c:forEach tag which gives you iterate your list so no need to write java code and iterate.
That JSTL tag provide you status attribute which gives you odd and even row status what you want. But you use it using division operation and find it is odd or even that gives JSTL. just put your color according to status attribute.
Emma Aziz - For all the design suggestions that you have got - your code is still correct the way it is. You could try putting a few System.out.println() statements in your JSP to find out how the flow is happening - that would give you some idea of whats going wrong...
Yes I agree with everyone out here that there are lot of design improvements that could be made to the code - it still does not answer the question why the current code is not working? Any thought on that?
and got no messages on server console !!
i think the scriplets aren't working ... m looking into why
Your code is incorrect. Its going to throw a class cast exception at line 33 --> ArrayList empList = (ArrayList) itr.next();
That because the itr.next() is going to return the String 'Aniruddh' which is the first element in the ArrayList.
The problem with the original code is on similar lines. Here is the code that works..
Frankly - the code does need a lot of redesign - would have loved to help more but running short of time right now ...
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.
Anyone here knows how to solve this? Am really helpless here.
Thanks in advance
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.
Anyone here knows how to solve this? Am really helpless here.
Thanks in advance
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.
Anyone here knows how to solve this? Am really helpless here.
Thanks in advance
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.
Anyone here knows how to solve this? Am really helpless here.
Thanks in advance
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.
Anyone here knows how to solve this? Am really helpless here.
As I see, you are using a List of Lists wherein you store employee information(like first name, last name etc) in a list and then add this list to another list which contains other such list of employee details.
And then in the JSP, you iterate over the main list and get its inner lists, each list containing employee details. The logic seems to be fine. Try putting log statements at various steps, or use a debugger and step through the code to figure out, what's going wrong.
but m not clear about you alternate color scheme.. and of course this code could be written in a better way
Satya Maheshwari
Ranch Hand
Joined: Jan 01, 2007
Posts: 368
posted
0
@Aniruddh Joshi
I agree your code works but I think the original code is slightly different and uses list of lists and you are using only a single list for 1 employee.
Did you solve this problem ? still scriptlets not working ?
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Hi Seetha,
I have just figured it out before Anirudh pointed it out
Hi Anirudh,
I've tried your codes and it is still, not working.
Hi Nishan,
There is no entry of that kind in my web.xml.
Hi Balu,
Yes, I have solved the problem. I removed and added again the Classpath in the Environment Variable, stop start service, and the problem, was solved.
I've tried putting some texts under the scriplets but anything didn't come out.
Thanks in advance.
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Hi Seetha,
I have just figured it out before Anirudh pointed it out
Hi Anirudh,
I've tried your codes and it is still, not working.
Hi Nishan,
There is no entry of that kind in my web.xml.
Hi Balu,
Yes, I have solved the problem. I removed and added again the Classpath in the Environment Variable, stop start service, and the problem, was solved.
I've tried putting some texts under the scriplets but anything didn't come out.
Thanks in advance.
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Hello,
Does anyone knows what is the solution? I've tried so many ways, the output are still the same.
Thanks.
Emma Aziz
Greenhorn
Joined: Apr 27, 2009
Posts: 23
posted
0
Hello All!
I am excited. I solved the problem. It is, surely, my web.xml configuration. Any scriplets under this application folder won't work, then I tried putting the jsp with a really simple scriptlets, is also not working. When I put them under other application folder, it worked.
So, I tried taking the other's web.xml, paste it under my application folder, and yes, the result is displayed.
I thanked all of you for helping me out of the block.
I am excited. I solved the problem. It is, surely, my web.xml configuration. Any scriplets under this application folder won't work, then I tried putting the jsp with a really simple scriptlets, is also not working. When I put them under other application folder, it worked.
So, I tried taking the other's web.xml, paste it under my application folder, and yes, the result is displayed.
I thanked all of you for helping me out of the block.
Thanks.
Hi Emma,
Did you really realize what is what is not working? Just copy pasting other xml can work but is better if you compare both to see what was going when it was not working, so the next time you will not lose time ;)