File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Instantiate a bean in a servlet and latter read it from jsp . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Instantiate a bean in a servlet and latter read it from jsp ." Watch "Instantiate a bean in a servlet and latter read it from jsp ." New topic
Author

Instantiate a bean in a servlet and latter read it from jsp .

Tirthankar Dutta Chaudhuri
Ranch Hand

Joined: Feb 26, 2005
Posts: 48
How can i Instantiate a bean in a servlet and latter read it from jsp using the use bean tag .

My code :
ResultBean rb= new ResultBean();
rb.setaName(Acc.getName());
rb.setaIATA(Acc.getIATA());
PageContext pagecontext = JspFactory.getDefaultFactory().getPageContext(this, request, response, null, true, 8192, true);
pagecontext.setAttribute("rb", rb);
//request.setAttribute("resultdata", rb);
System.out.println(" hi ----in servlet ------------"+Acc.getIATA());
srd = request.getRequestDispatcher("results.jsp");


In jsp i want to use the use bean tag
<jsp:useBean id="rb" class="result.ResultBean" scope="request"/>

i am not getting any value in the jsp page no error is also being shown .

How can i do what is required .

Thanks ,
Tirthankar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Just bind your resultBean to request scope.
SimpleMVC on http://simple.souther.us is an example of this.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instantiate a bean in a servlet and latter read it from jsp .