• 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

JSP String value obtained from servlet out

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pseudo code:

//Servlet
String theString = "Servlet's output String";
PrintWriter out = response.getWriter();
out.print(theString);


//JSP
<%
String thestringFromServlet = Servlet's output String;
%>





Is this possible?
TIA!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that you are getting to the JSP from the servlet via a forward, no. What is it that you're really trying to do? And is the assumption about the forward correct?

There are ways to get data from the servlet to the JSP, but the response buffer is not one of them.
[ March 14, 2007: Message edited by: Bear Bibeault ]
 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear,
thanks for the reply.
I am using the NTLM servlet to pull the authenticated username from the browser.
So for instance if I access the Servlet it prints out mydomain/gforte.
I was trying to "include" the Servlet in my jsp and "grab" that string(mydomain/gforte).

I could easily do this by accessing the Servlet first and then redirect to my jsp and pass this as a POST parameter OR set a session in the servlet and then redirect, but I was trying to keep it modular so that other apps could use it.

How else could I access a Variable called authenticatedUser (that resides in the Servlet) from my jsp without a redirect from the servlet?

Thanks for any tips!
[ March 14, 2007: Message edited by: g forte ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again that all depends upon the relationship berween the serlvet and the JSP.

Included? Forwarded? Redirected?
 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, Included.
Thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then scoped variables in request scope should do nicely.
 
reply
    Bookmark Topic Watch Topic
  • New Topic