Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Darren Alexandria
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Best of luck ...
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies. I will try your suggestions.
God bless.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic