• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Best of luck ...
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies. I will try your suggestions.
God bless.
reply
    Bookmark Topic Watch Topic
  • New Topic