aspose file tools*
The moose likes Servlets and the fly likes Treating servlet as a Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Treating servlet as a Bean" Watch "Treating servlet as a Bean" New topic
Author

Treating servlet as a Bean

Bala Krishna
Ranch Hand

Joined: Jan 26, 2001
Posts: 95
Is this possible? One of the solutions to the problem I am trying to solve demands this approach. I want to be able to call some methods in the servlet from JSPs, not just sending HTTP requests via forward, or sendredirect. The only hitch seems to be getting a handle to the instance of the servlet. Can some one please shed some light on how this can be done? Thanks.
-Bala
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
You can do this by having the servlet put itself into the session, but I think it would be a very dangerous and un-intuitive thing to do.
Why not create another class which does what you want, and call it both from your servlet and from the JSP?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
When I use a servlet, I only use it to handling request and response (collecting inser input to stuff beans, and direct tasks). Servlet can call othe help objects of other classes to perform certain task. My servlets normally only have two methods, doGet/doPost.
I think clean servlet is good design.
regards,
ruilin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Treating servlet as a Bean