Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

interaction between class and jsp  RSS feed

 
Jeff Sunder
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to JSP and servlets and would like some feedback on how to structure my application. I have a .class file which is a ConnectionPool manager. I originally wrote the file as a helper class to a servlet. But now I need that file to interact with JSP pages as well. Is it possible to have a class file interact with JSP pages? If so, how do I accomplish this? Or do I have to create a custom tag? If I change the class file to a custom tag, will the servlet be able to access the custom tag? If so, how is this done? Or do I make a class file into a Java bean? (If making a bean is the way to go, can any one point to any helpfule tutorials on wrirint Java Beans). What is the best structure to set up this application?
[This message has been edited by Jeff Sunder (edited July 17, 2001).]
[This message has been edited by Jeff Sunder (edited July 17, 2001).]
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JSP is essentially an inside-out servlet, so generally if you could do something in a servlet, you can do it in a JSP -- although if you get carried away, the JSP will be one in name only and for all practical purposes it will BE a servlet!
Since the idea behind JSPs is to better implement the MVC paradigm, wrapping stuff in JavaBeans and custom tags is a good idea, since they provide mechanisms to keep the view and controller parts separate, though there's no absolute requirement.
JavaBeans are a rich enough subject that I'd rather not take up space here - though at its simplest, any Java class that implements the serializable interface and has its properties accessed with set/get methods qualifies as a bean - custom tags are beans as well, though they carry a few additional rules. It's really not that difficult. You may want to start by just invoking your class the old way, then try converting it to a JavaBean or custom tag once you see how things work.
 
Jeff Sunder
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I call a custom tag from a servlet? If so, what is the syntax? If I made my ConnectionPool class into a servlet, how can I interact the servlet with a JSP page? That is how can I pass something like a Connection object to a JSP page?
[This message has been edited by Jeff Sunder (edited July 18, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!