The moose likes Servlets and the fly likes Using servlets with java beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using servlets with java beans " Watch "Using servlets with java beans " New topic

Using servlets with java beans

Giselle Dazzi
Ranch Hand

Joined: Apr 20, 2003
Posts: 168
Hi all,
Do you know how I can call beans methods from a servlet.
I mean, Im trying to find out how to do a

from inside a servlet instead of a jsp page.
I tried instantiating the bean class and then calling the get method I want but since it's a new instance, I dont see the content it has been set by the session.
Thx in advance,

Giselle Dazzi<br />SCJP 1.4
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
Hi Giselle,
The best way to see how you may call a javabean from a serlvet is to check the code of the servlet generated by your JSP page.
I'm sure you know that at translation time, JSP pages are converted into servlets..
So just cut and paste..

SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
and if you don't know if your using tomcat look in tomcat/work

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Giselle Dazzi
Ranch Hand

Joined: Apr 20, 2003
Posts: 168
thx, I got it, here's the code I used:
It is sorta covered in the JavaRanch Style Guide.
subject: Using servlets with java beans
jQuery in Action, 3rd edition