aspose file tools*
The moose likes JSP and the fly likes how can I send the output of a servlet to a jsp page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how can I send the output of a servlet to a jsp page?" Watch "how can I send the output of a servlet to a jsp page?" New topic
Author

how can I send the output of a servlet to a jsp page?

Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
I have a 2 servlets which reads and write data to and from RS232. To get the output, I must first run SimpleWrite.java then SimpleRead.java. As of the moment, the output is only shown in the console. How can I show the output on a jsp page? Thanks.

here is the code:

SimpleRead.java


SimpleWrite.java
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

Put the results in the request object, then dispatch the request to the JSP!

Best of luck ...


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
paritosh ranjan
Ranch Hand

Joined: Aug 24, 2007
Posts: 62
whatever data you want to send to the jsp wrap it up in a request,session or application scope object

like:
B b=new B();
request.setAttribute("a",b);
or
HttpSession session=request.getSession();
session.setAttribute("c",b);
or
ServletContext context=getServletContext();
context.setAttribute("d",b);


and then go to jsp page,ther you can use
Object getAttribute(String)

method for retrieving those those objects which you set in you servlet.Use the same scope to getAttribute in which you have set them.

if you have used session.setAttribute("c",b);

use session.getAttribute("c");

and so on.
Darren Alexandria
Ranch Hand

Joined: Aug 17, 2007
Posts: 185
Thanks for your replies. I will try your suggestions.
God bless.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how can I send the output of a servlet to a jsp page?