Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP -> servlet -> JSP

 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am working on learning JSP/Servlet. I need to know that how may i retrieve some data from servlet into JSP? as my servlet already is retrieving data from jsp.thank you.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by:
as my servlet already is retrieving data from jsp.
?
 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.. from an html page i am submitting form action to servlet. where I am retreiving data thru sql. now I want to display the selected data in another JSP. I just need to know how to link servlet to a new JSP. hope i cleared my question.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this describe what you're trying to do?

I assumed we wanted to get some data from the server, and elaborated a bit with the call to get data from the model. It's common for the servlet to get something from the database (for example) and put the data on the request, then forward to the JSP which gets that data and merges it into the response HTML.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, you answered my question while I was typing! Now the bad news: I do this so rarely I don't have the answer to your question memorized. I'll be back in a few minutes after I dig up an example.

Ok, I'm back. Look at:

[ June 12, 2005: Message edited by: Stan James ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did.

You'll want to read up on the RequestDispatcher interface.

You'll also want to learn how to bind your objects to the various 'scoped' objects that are available to JSP pages.
Section 13.4 in this chapter is helpful in this regard:
http://csajsp-chapters.corewebprogramming.com/CSAJSP-Chapter13.pdf

If you would like to see all of this being done in a very simple example, look at SimpleMVC from http://simple.souther.us
[ June 12, 2005: Message edited by: Ben Souther ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't anybody have anything better to do on Sunday night besides type faster than me?

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
Doesn't anybody have anything better to do on Sunday night besides type faster than me?



If I tried to type that ascii art UML sequence diagram I'd still be working on it and wouldn't look half as nice.
 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good good... both of you keep it up :roll: I got my answer. thanks.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a tool to make those diagrams, but last night I guess I forgot part of it was case sensitive. I sat for a few minutes scratching my head.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic