File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Beans in Servlet

 
Sean Casey
Ranch Hand
Posts: 625
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm having trouble initializing a bean in a servlet and then using it in another jsp page that I forward to with the Request Dispatcher. Can some one tell me what's wrong with this? The following is the relevant Servlet code:
public void init() throws ServletException{
testerBean testBean= new testerBean();
testBean.setMessage("THIS SHOULD WORK");
getServletContext().setAttribute("testBean", testBean);
The bean is in a package called core.
Here's the JSP tag I'm using:
<jsp:useBean id="testBean" class="core.testerBean"
scope="application" />
<jsp:getProperty name="testBean"
property="message" />
I'm trying to initialize the bean in the servlet, including the message attribute of the bean, and then fowarding to the jsp page so the jsp page can use the bean. I'm getting the default message I set up in the bean class. Any help would be great. I've already looked at the Core JSP book, and the Oreilly JSP book, but I think I'm missing something.
thanks, Sean.
 
Sean Casey
Ranch Hand
Posts: 625
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as usually is the case, I'm an idiot. I kept recompiling the servlet without restarting the server, so the changes weren't being demonstrated in the jsp page. Everything works fine now.

[This message has been edited by Sean Casey (edited September 09, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic