Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP String value obtained from servlet out

 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Sorry, Included.
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then scoped variables in request scope should do nicely.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic