Re: Servlet chaining, set remoteUser?
Since this only really has a chance of working with a 2.3+ container (like Tomcat 4.x), I'd probably use a Filter instead of chaining Servlets. However, the idea is the same. You create a HttpServletRequestWrapper that overrides getRemoteUser and getUserPrincipal (and, possibly, isUserInRole) that understands the Domino authentication. You then pass the Wrapper along in the chain so that the destination Servlet gets the correct values for the above. Jim Henderson [EMAIL PROTECTED] wrote in message 003301c2c313$8cdf8910$[EMAIL PROTECTED]">news:003301c2c313$8cdf8910$[EMAIL PROTECTED]... I have an existing Servlet that requires an authenticated user (HttpServletRequest.getRemoteUser()). However, the Servlet can now be invoked from another application on a Domino server which the user has already signed on to.The Domino server will redirect the request to my Servlet and pass the user ID in a file. To avoid changing my original Servlet I want to try Servlet Chaining. However, how do I set the userID in the redirected request stream? Is that possible? Thanks! Jim Henderson -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Servlet chaining
try struts - jakarta.apache.org/struts I think Reynir Hübner wrote: hi everyone, Does anyone know of implementation of a good ServletChaining API (for tomcat) that´s available for download ? I know Filters will be introduced into Tomcat 4 and I look forward to working with those but untill it will be released I need something similar. thanx bye -r
RE: servlet chaining, session null
ok, but it's between the second and the third servlet that the problem appears !!! -Message d'origine- De: Bo Xu [SMTP:[EMAIL PROTECTED]] Date: jeudi 17 mai 2001 20:52 À:[EMAIL PROTECTED] Objet:Re: servlet chaining, session null [EMAIL PROTECTED] wrote: Well, all my servlets are on the same webapps. I don't use the url rewriting, but the HttpSession. for example in the first servlet: HttpSession session = request.getSession(false); if (session == null) session = request.getSession(true); session.setAttribute(path1,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet2 ); dispatch.forward(request,response); in Servlet2 HttpSession session = request.getSession(false); session.setAttribute(path2,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet3 ); dispatch.forward(request,response); I do the same in the third servlet, but when i test my session, it's null. That's funny, but it only happen the first time i send the request, the second time, everything works fine !!! [...] Hi :-) I am not sure, is the following possibe? in the first time, because you use getRequestDispatcher, so the new cookie which includes JSESSIONID made by MyServlet1 hasn't got the time Yet to goto :-) MyServlet2/3. in the second time, that cookie(made by MyServlet1) has already been received by the browser of your client, and re-sent to MyServlet1/2/3, so now in MyServlet2/3, session is not null. Bo May.17, 2001
Re: servlet chaining, session null
[EMAIL PROTECTED] wrote: Hi, i'm trying to use Servlet chaining with three servlets. In the first one i create a cession (if it doesn't exist), in the second one i put some attributes in the cession. But when i arrive in the third servlet, my session is null? As anybody already had this problem ? Is it possible to get the path of the servlet who called the last one ? I mean if i am in the ith servlet, how can i get the path of the (i-1)th servlet ? [...] Hi :-) I am not sure, I just suggest you to notice: - do you use cookie or url-rewritting or other to make your session-tracking? if you are using url-rewritting, don't forget to use HttpServletResponse.encodeURL/encodeRedirectURL to encode the URL(make a new URL which includes the JSESSIONID), I guess it is also possible to add JSESSIONID by myself with HttpSession.getId() - from several emails, HttpSession is within a special webapp, so if in your Servlet-chain, you go to another Servlet-class which is in another webapp, now perhaps another new session will/need-to be made. Bo may.17, 2001
RE: servlet chaining, session null
Well, all my servlets are on the same webapps. I don't use the url rewriting, but the HttpSession. for example in the first servlet: HttpSession session = request.getSession(false); if (session == null) session = request.getSession(true); session.setAttribute(path1,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet2); dispatch.forward(request,response); in Servlet2 HttpSession session = request.getSession(false); session.setAttribute(path2,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet3); dispatch.forward(request,response); I do the same in the third servlet, but when i test my session, it's null. That's funny, but it only happen the first time i send the request, the second time, everything works fine !!! Strange !!! -Message d'origine- De: Bo Xu [SMTP:[EMAIL PROTECTED]] Date: jeudi 17 mai 2001 16:29 À:[EMAIL PROTECTED] Objet:Re: servlet chaining, session null [EMAIL PROTECTED] wrote: Hi, i'm trying to use Servlet chaining with three servlets. In the first one i create a cession (if it doesn't exist), in the second one i put some attributes in the cession. But when i arrive in the third servlet, my session is null? As anybody already had this problem ? Is it possible to get the path of the servlet who called the last one ? I mean if i am in the ith servlet, how can i get the path of the (i-1)th servlet ? [...] Hi :-) I am not sure, I just suggest you to notice: - do you use cookie or url-rewritting or other to make your session-tracking? if you are using url-rewritting, don't forget to use HttpServletResponse.encodeURL/encodeRedirectURL to encode the URL(make a new URL which includes the JSESSIONID), I guess it is also possible to add JSESSIONID by myself with HttpSession.getId() - from several emails, HttpSession is within a special webapp, so if in your Servlet-chain, you go to another Servlet-class which is in another webapp, now perhaps another new session will/need-to be made. Bo may.17, 2001
Re: servlet chaining, session null
[EMAIL PROTECTED] wrote: Well, all my servlets are on the same webapps. I don't use the url rewriting, but the HttpSession. for example in the first servlet: HttpSession session = request.getSession(false); if (session == null) session = request.getSession(true); session.setAttribute(path1,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet2); dispatch.forward(request,response); in Servlet2 HttpSession session = request.getSession(false); session.setAttribute(path2,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet3); dispatch.forward(request,response); I do the same in the third servlet, but when i test my session, it's null. That's funny, but it only happen the first time i send the request, the second time, everything works fine !!! [...] Hi :-) I am not sure, is the following possibe? in the first time, because you use getRequestDispatcher, so the new cookie which includes JSESSIONID made by MyServlet1 hasn't got the time Yet to goto :-) MyServlet2/3. in the second time, that cookie(made by MyServlet1) has already been received by the browser of your client, and re-sent to MyServlet1/2/3, so now in MyServlet2/3, session is not null. Bo May.17, 2001
RE: servlet chaining, session null
I have found problems when you are you using separate contexts for servlets that share session information on the server. I don't know if the crosscontext flag helps this. Ross -Original Message- From: Bo Xu [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 17, 2001 12:52 PM To: [EMAIL PROTECTED] Subject: Re: servlet chaining, session null [EMAIL PROTECTED] wrote: Well, all my servlets are on the same webapps. I don't use the url rewriting, but the HttpSession. for example in the first servlet: HttpSession session = request.getSession(false); if (session == null) session = request.getSession(true); session.setAttribute(path1,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet2); dispatch.forward(request,response); in Servlet2 HttpSession session = request.getSession(false); session.setAttribute(path2,request.getServletPath()); RequestDispatcher dispatch = this.getServletContext().getRequestDispatcher(/servlet/chaining.Servlet3); dispatch.forward(request,response); I do the same in the third servlet, but when i test my session, it's null. That's funny, but it only happen the first time i send the request, the second time, everything works fine !!! [...] Hi :-) I am not sure, is the following possibe? in the first time, because you use getRequestDispatcher, so the new cookie which includes JSESSIONID made by MyServlet1 hasn't got the time Yet to goto :-) MyServlet2/3. in the second time, that cookie(made by MyServlet1) has already been received by the browser of your client, and re-sent to MyServlet1/2/3, so now in MyServlet2/3, session is not null. Bo May.17, 2001
RE: Servlet Chaining...
Title: RE: Servlet Chaining... [Gaël Oberson] I think HttpServletRequest inherits getRequestDispatcher(..) from ServletRequest class and does implement it. [Gaël Oberson] You can also get the RequestDispatcher object from ServletContext Yes, you're right, but it'snot what I want to do. the forward methodsends the request and response objects to another servlet or jsp, and the response is entierely created by the second servlet. The incude method "concatenates" the ouput from servlet 1 servlet 2 in the same response object. But, in my case, the servlet 1 generates dynamic XML from a database, and the servlet 2 (Cocoon) generates HTML FROM servlet1's XML data... Do you see what I mean? The data is processed twice! Ok. And now how to do that The first that can provide me a working solution wins a beer... Thx.
RE: Servlet Chaining...
Servlet1 doesn't have to output anything to the standard PrintWriter in your case. You could conditionally output to a buffer and then handle this buffer to servlet2. Maybe some custom object inheriting from Response passed as Request attribute... I assume that you ALSO want servlet1 to be able to directly output XML to clients... don't you? A better solution would be to have an independent component that could be called from servlet1 and servlet2. -Mensaje original- De: Gal Oberson [SMTP:[EMAIL PROTECTED]] Enviado el: jueves 5 de abril de 2001 18:05 Para: [EMAIL PROTECTED] Asunto: RE: Servlet Chaining... [Gal Oberson] I think HttpServletRequest inherits getRequestDispatcher(..) from ServletRequest class and does implement it. [Gal Oberson] You can also get the RequestDispatcher object from ServletContext Yes, you're right, but it's not what I want to do. the forward method sends the request and response objects to another servlet or jsp, and the response is entierely created by the second servlet. The incude method "concatenates" the ouput from servlet 1 servlet 2 in the same response object. But, in my case, the servlet 1 generates dynamic XML from a database, and the servlet 2 (Cocoon) generates HTML FROM servlet1's XML data... Do you see what I mean? The data is processed twice! Ok. And now how to do that The first that can provide me a working solution wins a beer... Thx.
Re: Servlet Chaining...
Bo, Did you use Cygwin to build the mod_webapp connector? I am having a problem to build it. Can you share the info with us? Pae -Original Message- From: Bo Xu [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Thursday, April 05, 2001 8:57 AM Subject: Re: Servlet Chaining... "Grewal, Gary" wrote: I think HttpServletRequest inherits getRequestDispatcher(..) from ServletRequest class and does implement it. You can also get the RequestDispatcher object from ServletContext === Gary Grewal [...] Hi :-) yes, I did a test with jakarta-tomcat-4.0-b3(standalone, JDK1.3, winnt40): * both the following can work: - getServletContext().getRequestDispatcher(...).forward(request, response) - request.getRequestDispatcher(...).forward(request, response) * both the following is the same one(has the same hashCode) - rd0=getServletContext().getRequestDispatcher(...) - rd1=request.getRequestDispatcher(...) rd0.hashCode() is same with rd1.hashCode() Bo Apr.05, 2001
Re: Servlet Chaining...
Gal Oberson wrote: [Gal Oberson] I think HttpServletRequest inherits getRequestDispatcher(..) from ServletRequest class and does implement it. [Gal Oberson] You can also get the RequestDispatcher object from ServletContext Yes, you're right, but it's not what I want to do. the forward method sends the request and response objects to another servlet or jsp, and the response is entierely created by the second servlet. The incude method "concatenates" the ouput from servlet 1 servlet 2 in the same response object. But, in my case, the servlet 1 generates dynamic XML from a database, and the servlet 2 (Cocoon) generates HTML FROM servlet1's XML data... Do you see what I mean? The data is processed twice! Ok. And now how to do that The first that can provide me a working solution wins a beer... Thx. [...] Hi :-) first, the most important, we must make the following clear: :-) - if I have n ideas, can I have n beers? if(not), return; :-) - if my ideas are all not right, but because they are more than one, and I type a lot of words with keyboard, so can I also have 1 beer? if(not), return; :-) I am not sure, I have some suggestions: * use - ServletContext.getAttribute(...)/setAttribute(...) and - RequestDispatcher/sendRedirect to pass the XML data from MyServlet0 to MyServlet1 * use - HttpSession.getAttribute(...)/setAttribute(...) and - RequestDispatcher/sendRedirect to pass the XML data from MyServlet0 to MyServlet1 * use - (Http)ServletRequest.getAttribute(...)/setAttribute(...) and - RequestDispatcher/sendRedirect to pass the XML data from MyServlet0 to MyServlet1 * use - MyHelper which is loaded by Shared classloader to save data and - RequestDispatcher/sendRedirect to pass the XML data from MyServlet0 to MyServlet1 * and from several emails, perhaps it is better to make the object which "wrap" the XML data Serializable. * another "non-OO" way is : if it is possible to "put" the XML data in a String which is not very long, we also can use: RequestDispatcher rd=request.getRequestDispatcher("/servlet/MyServlet1?tailPxml=..."); rd.forward(request, response); my most favorate bear brand is ... //hahahahaha :-) Bo Apr.05, 2001
RE: Servlet Chaining...
no no no no no no... you all have good ideas, but all these ideas will not work for my problem. The second servlet, wich must process XML - HTML, is Cocoon (xml.apache.org/cocoon), and I have no ideas about the parameters Cocoon Can take!! Cocoon is normally designed to process "static" XML + XSL pages that are located on the server... So who wants the first beer??
Re: Servlet Chaining...
Could you use a request dispatcher to forward the request to the second servlet? From the first servlet's request object you could code this: RequestDispatcher rd = req.getRequestDispatcher("path to second servlet"); rd.forward(); --- Gaël_Oberson [EMAIL PROTECTED] wrote: Hello I try to use Servlet Chaining with Tomcat. Can I do that with a tag in the web.xml file (with servlet-mapping for example), or must I modify my Request parameters?? does anyone know how to do that??? I have a Servlet that generates an complete and valid XML file from a database, and this file must be processed by the Cocoon servlet and then be returned to the client. That's it. Can anyone help me please??? Thanks. *** Gaël Oberson Computer scientist Student in Computer Science Engineering (HES) Switzerland [EMAIL PROTECTED] [EMAIL PROTECTED] *** = ~~~ Scott __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/
RE: Servlet Chaining...
No, it doesn't work, because the HttpServletRequest class used in HttpServlet doesn't implement the getRequestDispatcher method... But it we can make your idea work, I don't understand how my XML file is sent to the cocoon servlet... My XML file is printed do the response (out.print(String);), and with the forward() method, the XML data is not sent.. How does it work?? -Message d'origine- De : Scott Walter [mailto:[EMAIL PROTECTED]] Envoye : mercredi, 4. avril 2001 19:33 A : [EMAIL PROTECTED] Objet : Re: Servlet Chaining... Could you use a request dispatcher to forward the request to the second servlet? From the first servlet's request object you could code this: RequestDispatcher rd = req.getRequestDispatcher("path to second servlet"); rd.forward(); --- Gakl_Oberson [EMAIL PROTECTED] wrote: Hello I try to use Servlet Chaining with Tomcat. Can I do that with a tag in the web.xml file (with servlet-mapping for example), or must I modify my Request parameters?? does anyone know how to do that??? I have a Servlet that generates an complete and valid XML file from a database, and this file must be processed by the Cocoon servlet and then be returned to the client. That's it. Can anyone help me please??? Thanks. *** Gakl Oberson Computer scientist Student in Computer Science Engineering (HES) Switzerland [EMAIL PROTECTED] [EMAIL PROTECTED] *** = ~~~ Scott __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/
Re: Servlet Chaining...
Look at the "web.xml" and its DTD. Pae -Original Message- From: Gael Oberson [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Date: Wednesday, April 04, 2001 10:47 AM Subject: RE: Servlet Chaining... No, it doesn't work, because the HttpServletRequest class used in HttpServlet doesn't implement the getRequestDispatcher method... But it we can make your idea work, I don't understand how my XML file is sent to the cocoon servlet... My XML file is printed do the response (out.print(String);), and with the forward() method, the XML data is not sent.. How does it work?? -Message d'origine- De : Scott Walter [mailto:[EMAIL PROTECTED]] Envoye : mercredi, 4. avril 2001 19:33 A : [EMAIL PROTECTED] Objet : Re: Servlet Chaining... Could you use a request dispatcher to forward the request to the second servlet? From the first servlet's request object you could code this: RequestDispatcher rd = req.getRequestDispatcher("path to second servlet"); rd.forward(); --- Gakl_Oberson [EMAIL PROTECTED] wrote: Hello I try to use Servlet Chaining with Tomcat. Can I do that with a tag in the web.xml file (with servlet-mapping for example), or must I modify my Request parameters?? does anyone know how to do that??? I have a Servlet that generates an complete and valid XML file from a database, and this file must be processed by the Cocoon servlet and then be returned to the client. That's it. Can anyone help me please??? Thanks. *** Gakl Oberson Computer scientist Student in Computer Science Engineering (HES) Switzerland [EMAIL PROTECTED] [EMAIL PROTECTED] *** = ~~~ Scott __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/
Re: Servlet chaining in Tomcat
Rama Venkata Kunapuli wrote: Folks: I am trying to chain servlets so output of one is directed to next servlet. Lacking information, I have tried modifying web.xml and made the following entries -- ofcourse, it didn't work! servlet servlet-nameServletChain/servlet-name servlet-classSimpleTextServlet,UpperCaseServlet/servlet-class /servlet servlet-mapping servlet-nameServletChain/servlet-name url-pattern/cha/url-pattern /servlet-mapping Output of SimpleTextServlet is supposed to go to UpperCaseServlet. Any suggestions on how to make this work ? Servlet chaining is not supported by Tomcat, and is quite unlikely to ever be supported. It is not in the servlet spec, so you will find that many servlet containers don't support it, and some may support it in different ways. As a programming technique, servlet chaining is also fraught with problems. The recommended approach (from a servlet API perspective) is to use the new Filter capability that was added in Servlet 2.3 (and implemented in Tomcat 4.0). Thanks, Rk Craig McClanahan