How to display values from another class file<br>!_NEWLINE_!without passing a response object
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Thursday, September 27, 2001 11:04 PM

Hi I have a servlet that displays some data. When there is a need of accessing the database and display the result, I call another class file to do it. For that I use this code in class1. Class2 cl2=new Class2() ; cl2.showResult(res); where "res" is the HttpServletResponse object. In Class2 I use this method to show the result. void showResult(HttpServletResponse res) { PrintWriter pw=res.getWriter(); ......code....... } Here I am passing a Response object from one class to another to display the va   More>>

Hi



I have a servlet that displays some data.

When there is a need of accessing the database and display the result,

I call another class file to do it.



For that I use this code in class1.


Class2 cl2=new Class2() ;

cl2.showResult(res);


where "res" is the HttpServletResponse object.



In Class2 I use this method to show the result.


void showResult(HttpServletResponse res)

{


PrintWriter pw=res.getWriter();


......code.......


}




Here I am passing a Response object from one class to another

to display the values from the second class.

But In JSP we can display the values from a bean or another JSP file

without pasing a response object.
Is it possible with RequestDispatcher object in servlet.

In JSP we can forward a page by just using tag and there

is no need of a response object.Can I do the same in servlet.


I could not find the answer from the FAQ.Could you pls include a sample code




thanks


sabu

   <<Less

Re: How to display values from another class file<br>!_NEWLINE_!without passing a response object

Posted By:   Mittal_Bhiogade  
Posted On:   Friday, September 28, 2001 04:23 AM

I am assuming u have got some object from u from some class...now that object needs to be passed either to some jsp or some servlet u can do two things..
1)Put that object into session and forward to the desire jsp or servlet
2)Attach the object(ur object) to the request object by using request.setAttribute(key,value) method
and forward it to the desired JSP or SERVLET
About | Sitemap | Contact