This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I have been working through some of the previous errors i had, and now i want to try and validate that everything is working on the jsp side. I have create a combobox within a form like so
Now when the user selects a value from the above combo box, does it get saved into Events? Because my next step in my PrintResultsServlet, i am doing this
And i just wanted to check that this would work, because i am not getting the desired output yet, so i want to rule this out if i can.
thanks
Ok, get you, so here is my major problem. So my selecting of events is in a form which is linked to my PrintResults servlet. In my servlet, i do thi
Now that should (or so i think) get the event, send it of to my database through a method, get returned a list and then forward this list back to my PrintResults.jsp. I know i have a successful list getting to my servlet, because at the bottom, i put a main method to test
And this returns me back the three fastest competitors for the 100M Run.
So now back to the jsp. I try to get the request and display it in a table. SO this is what i have done (problably tottally wrong but i have tried so many things)
As far as what happens, i am being returned an empty white page. Can you see where i might be going wrong?
thanks
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
As said, the cast is unnecessary.
Didn't you probably mean printCompetitors(event) instead? You're now passing the literal String instead of the variable you got.
Completely unnecessary. You should also not be writing scriptlets. Everytime you think you need scriptlets, there's a flaw in your design. Think twice about it then.
Nick Price
Greenhorn
Joined: Jan 03, 2009
Posts: 25
posted
0
Sorry, meant a hardcoded event, i was previously trying to pass it a String incase my "combo box" was not working. so i have forwarder the list to my jsp. If i dont need a scriplet, how would i display the list in my jsp?
What exactly is it that you think that scriptlet is doing for you?
Not only are scriptlets to be avoided like the plague, but this one is completely superfluous.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
Nick Price wrote:If i dont need a scriplet, how would i display the list in my jsp?
In ELroughly translates towhich scans for the attribute value associated with the given key in all scopes (page, request, session and application) and thus on its turn roughly translates to the following when you have placed it in the request scope using HttpServletRequest#setAttribute()With other words, your scriptlet is completely unnecessary.
Nick Price
Greenhorn
Joined: Jan 03, 2009
Posts: 25
posted
0
thats what i am trying to understand better so i can get rid of the scriplet. I thought that scriplet was getting the forwarded list i forward in my servlet. What i am trying to find out is how i can disply my list in my jsp. I have forwarded the list from my servlet to my jsp, so how do i retrieve this?
Sorry, i seem to struggle when it comes to jsp and servlets. Does that mean to get my list, i just place
request.getAttribute("searchResults");
in my jsp?
Or would you have any simple examples or tutorials that can show me the correct way to do this.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
Nick Price wrote:thats what i am trying to understand better so i can get rid of the scriplet. I thought that scriplet was getting the forwarded list i forward in my servlet. What i am trying to find out is how i can disply my list in my jsp. I have forwarded the list from my servlet to my jsp, so how do i retrieve this?
You already did it by putting it in the request scope using HttpServletRequest#setAttribute(). The problem lies somewhere else. Your list may be for instance empty. Or the application may have thrown an exception. Debug your code (do a sysout of the list immediately after retrieving it from the DAO), check both the HTML source and the application server logs for some oddities.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
Nick Price wrote:
Sorry, i seem to struggle when it comes to jsp and servlets. Does that mean to get my list, i just place
request.getAttribute("searchResults");
in my jsp?
No, just ${searchResults} as you already did.
Or would you have any simple examples or tutorials that can show me the correct way to do this.
This is covered by Sun Java EE tutorial. Also at the JSP/Servlet part of my DAO tutorial you can find examples of how the stuff ought to work.
Nick Price
Greenhorn
Joined: Jan 03, 2009
Posts: 25
posted
0
Where abouts would i find your DAO tutorial? I cant seem to find it anywhere on this site.
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
Nick Price wrote:Where abouts would i find your DAO tutorial? I cant seem to find it anywhere on this site.
Somthing has happened since last time, i looked at your further exercises part which helped a lot. I am pretty sure that my list is getting to my servlet, cos i can display it if i add a main to my servlet class. I founf there was a problem when i called it up in my jsp. I was using the wrong name. So i changed it and now i get an error, which seems more hopeful than before. It displays
Then some stacktrace. An then it gives me the root cause
Not understanding as to why it needs to be converted to an integer, or if its trying to convert to an integer. Any clues about this error?
cheers
Sorry, not quite understanding, printResult shouldnt be a String object, it should be a list of my own object Type. So how can i get rid of this error?
Bauke Scholtz
Ranch Hand
Joined: Oct 08, 2006
Posts: 2458
posted
0
Shouldn't the items be ${printResults} or so?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.