Forums Register Login

Opening a page with details about an item (servlet)

+Pie Number of slices to send: Send
Hi!

I am trying to create a web application in java. I am using servlets. I have come to the stage where the user enters a search query and receives a list of items which match his/her query. When the user gets a list of items which match, how can I make it possible for the user to click on an item and it opens a "show" servlet page and this takes the information regarding the item and displays them in this page?


I have tried the below code but this occurs before the list even appears:



I don't know whats wrong.

Thanks for any replies
+Pie Number of slices to send: Send
First of all this is a very bad practice. You should be using servlets only as controllers, and the view should be a JSP, or even a static HTML page with some AJAX. But either way, to get the result you need to display the results to the user in some table [which you are not doing], and the javascript invocation you are doing is wrong.

onClick='openItemDetails(itemToGet.getId())' should be changed to onClick='openItemDetails(<%=itemToGet.getId()%>)'

since itemToGet.getId() is a java object and not a javascript object.

Dawn.
+Pie Number of slices to send: Send
do you know any good tutorials how to use servlets as controllers?

I'm sorry for my question - I'm still learning how to use everything
+Pie Number of slices to send: Send
head first servlets and JSPs are my personal favourite....
+Pie Number of slices to send: Send
Please read this article.
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1084 times.
Similar Threads
RequestDispatcher Include
retrieve value at servlet from javascript.
Deleting multiple records using jQuery-ajax at a time.
Servlet API 2.2
servlet exception error in my code(urgent)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 22:03:44.