• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

interaction between class and jsp

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Saloon Keeper
Posts: 24283
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
reply
    Bookmark Topic Watch Topic
  • New Topic