Why does that effect the HttpServletRequest object? If you look at the code it evaluates the header and query string values before I access the trafficcop object. I will give it a try.
-cb -----Original Message----- From: Tim Funk [mailto:[EMAIL PROTECTED]] Sent: Monday, December 16, 2002 12:40 PM To: Tomcat Users List Subject: Re: Simultaneous request from same IP Is TrafficCop.java thread safe? If not - that is your problem. Both requests are using the same trafficCop instance. -Tim Chris Bick wrote: > No offense taken. I still can't believe that this problem may exist. > If you can find a problem with my code, that would be much easy then > getting a fix into tomcat. > > Thanks, > -cb > > > > import javax.servlet.*; > import javax.servlet.http.*; > import java.io.*; > import java.util.*; > > import java.net.*; > > > /** > * <p>Title: </p> > * <p>Description: </p> > * <p>Copyright: Copyright (c) 2002</p> > * <p>Company: </p> > * @author not attributable > * @version 1.0 > */ > > public class TrafficCopServlet extends HttpServlet { > private static final String CONTENT_TYPE_XML = "text/xml"; > private static final String CONTENT_TYPE_HTML = "text/html"; > /**@todo set DTD*/ > private static final String DOC_TYPE = null; > //Initialize global variables > > private TrafficCop trafficCop; > public void init() throws ServletException > { > trafficCop = new TrafficCop(false); > } > > //Process the HTTP Get request > public void doGet(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException { > PrintWriter out = response.getWriter(); > > try > { > if (request.getRequestURI().endsWith("/insert")) > { > response.setContentType(CONTENT_TYPE_XML); > out.println("<?xml version=\"1.0\"?>"); > > String pcpVersion = request.getHeader("PCP-Client-Version"); > String clientId = request.getHeader("PCP-Client-ID"); > String listenIP = request.getHeader("Listen-IP"); > String behindFirewall = request.getHeader("Behind-Firewall"); > > String urn = request.getQueryString(); > > synchronized(System.out) > { > System.out.println("URN:" + request.getQueryString()); > System.out.println(request.getHeader("Listen-IP")); > } > //System.out.println("Listen-IP:" + listenIP); > > if (pcpVersion == null || clientId == null || > listenIP == null || behindFirewall == null || > urn == null) > { > String error = "<error>Bad Headers</error>"; > out.println(error); > return; > } > > String xml = trafficCop.add(urn,new > URL(null,"pcp://"+listenIP,new Handler()), new > Boolean(behindFirewall).booleanValue(), 0); > > System.out.println(xml); > out.println(xml); > } > else if (request.getRequestURI().endsWith("/delete")) > { > response.setContentType(CONTENT_TYPE_XML); > out.println("<?xml version=\"1.0\"?>"); > > String clientId = request.getHeader("PCP-Client-ID"); > String sessionId = request.getHeader("My-Session-ID"); > String deleteSessionId = request.getHeader("Delete-Session-ID"); > String listenIP = request.getHeader("Listen-IP"); > String behindFirewall = request.getHeader("Behind-Firewall"); > > String completed = request.getHeader("Completed"); > String elapsedTime = request.getHeader("Elapsed-Time"); > String avgDownstream = request.getHeader("Average-Downstream"); > > String urn = request.getQueryString(); > > if (clientId == null || sessionId == null || > deleteSessionId == null || listenIP == null || > behindFirewall == null) > { > String error = "<error>Bad Headers</error>"; > out.println(error); > return; > } > > String xml = trafficCop.remove(urn, deleteSessionId, > sessionId,new URL(null,"pcp://"+listenIP, new Handler()), > new > Boolean(behindFirewall).booleanValue(),0,0); > > System.out.println(xml); > out.println(xml); > } > else if (request.getRequestURI().endsWith("/update")) > { > response.setContentType(CONTENT_TYPE_XML); > out.println("<?xml version=\"1.0\"?>"); > > String clientId = request.getHeader("PCP-Client-ID"); > String sessionId = request.getHeader("My-Session-ID"); > String listenIP = request.getHeader("Listen-IP"); > String behindFirewall = request.getHeader("Behind-Firewall"); > > String urn = request.getQueryString(); > > if (clientId == null || sessionId == null || > listenIP == null || behindFirewall == null) > { > String error = "<error>Bad Headers</error>"; > out.println(error); > return; > } > > String xml = trafficCop.connectionUpdate(urn, sessionId,new > URL(null,"pcp://"+listenIP,new Handler()), > new > Boolean(behindFirewall).booleanValue(),0,0); > > System.out.println(xml); > out.println(xml); > } > } > catch (Exception e) > { > out.println("<error>"+e.getMessage()+"</error>"); > e.printStackTrace(); > } > } > } > > -----Original Message----- > From: Tim Funk [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 16, 2002 12:21 PM > To: Tomcat Users List > Subject: Re: Simultaneous request from same IP > > Can you post an example servlet (or the real code) that can reproduce > this? (No offense but ...) I really think there ios something with your > code. > > -Tim > > Chris Bick wrote: > >>I've reproduced this problem with tomcat 3.2 and every version of 4.1 > > up > >>to 4.1.12 >> >>I haven't gone any further than all headers being identical and the >>query string. I thought maybe tomcat was just passing in the same >>reference, but the toString() value of the HttpServletRequest object > > are > >>different. >> >>Let me know if anyone can reproduce this?(If you have the time...) >> > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>