• Post Reply Bookmark Topic Watch Topic
  • New Topic

Kindly help with servlet jsp interaction  RSS feed

 
nash avin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a jsp page that has series of checkboxes for course and questions.

I have a servlet that takes the checked values from the jsp and gets the required answer for that particular course checked(from the database).This is done using System.out.println()'s, it is done on the console.I have used a for loop pertaining to each course, there is a select query that would select the answers to the questions checked, loops around for each course that is checked, hope what has been done is clearly explained.

I would like to do the same on the browser using a .jsp page, i.e., the servlet calls the .jsp page.For each course that is checked the answers are to be displayed .Help as to how I can proceed doing this would be greatly appreciated.

i.e.,

RequestDispatcher dispatcher = request.getRequestDispatcher("question_answer.jsp");
dispatcher.include(request, response);




I hope I have conveyed the question in detail.

TIA
AS
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I would do is have your servlet instantiate a Map such as HashMap. I would then populate the HashMap with the question number as the key, and the answer as the value. I would then give the request object access to this HashMap with the following statement:


once this is done, you can have the jsp reference the hashmap and display the contents, either with

or with a scriptlet such as:

[ March 09, 2005: Message edited by: Merrill Higginson ]
 
nash avin
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks a lot for the reply.I will work on what you have just stated and will get back with more questions.Thanks a lot again for the suggestion.

AS
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!