Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 79816 invoked from network); 11 Jul 2006 11:24:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Jul 2006 11:24:50 -0000 Received: (qmail 48593 invoked by uid 500); 11 Jul 2006 11:24:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 48566 invoked by uid 500); 11 Jul 2006 11:24:36 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 48554 invoked by uid 99); 11 Jul 2006 11:24:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 04:24:36 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [64.34.173.90] (HELO vhs1.asianetindia.com) (64.34.173.90) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Jul 2006 04:24:34 -0700 Received: (qmail 12078 invoked by uid 1014); 11 Jul 2006 11:24:27 -0000 Received: from vinu@x-minds.org by vhs2.linuxense.com by uid 1003 with qmail-scanner-1.22 (clamdscan: 0.74. spamassassin: 2.63. Clear:RC:0(61.17.42.35):SA:0(2.6/5.0):. Processed in 6.34093 secs); 11 Jul 2006 11:24:27 -0000 X-Spam-Level: ++ Received: from static-61.17.42.35.ip-dsl-tvm.eth.net (HELO [192.168.0.5]) (vinu@x-minds.org@[61.17.42.35]) (envelope-sender ) by vhs1.asianetindia.com (qmail-ldap-1.03) with SMTP for ; 11 Jul 2006 11:24:20 -0000 Message-ID: <44B38B81.7010409@x-minds.org> Date: Tue, 11 Jul 2006 16:59:05 +0530 From: Vinu Varghese Organization: X-minds User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Getting the date/time from the client References: <44B35878.6040405@x-minds.org> <009a01c6a4c0$33540be0$6500a8c0@vancouver> <44B36038.6010104@x-minds.org> <00de01c6a4c8$8b2acbd0$6500a8c0@vancouver> <44B36E20.6010301@x-minds.org> <44B37C37.7050807@mkodo.com> <44B3808C.1080403@pidster.com> In-Reply-To: <44B3808C.1080403@pidster.com> Content-Type: multipart/alternative; boundary="------------070005080206070505080103" X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, hits=2.6 required=5.0 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------070005080206070505080103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit but that still sets the server date - yes ? Pid wrote: > write a filter that activates for that url, and get the time just before > you doFilter. if you need to, you can pass the date obj as an attribute > > Date date = new Date(); > hreq.setAttribute("thisIsTheDate", date); > chain.doFilter(hreq, hres); > > > > Jon Wingfield wrote: > >> The HTTP spec (rfc2616) says clients should only send the Date header >> with http messages with body content (POST, PUT) and even then it's >> optional. >> >> Try adding a date string as a parameter on your GET request which your >> servlet can then parse from request.getParameter(...). >> >> One way to do this would be to change your link to a form with a hidden >> input field for your date value. Add an onclick/onsubmit javascript >> handler to your form button which sets the value of the hidden field to >> the current date in a format that your servlet will understand. >> >> for example: >> >> function setDate(form) { >> form.dateField.value = new Date().toString(); >> } >> >> >> Example assumes a hidden form input field with name dateField. >> >> HTH, >> >> Jon >> >> Vinu Varghese wrote: >> >>> SK, >>> That javascript prints the current client time. But I want the client >>> time with the request. >>> The scenario is : >>> >>> I have a index.jsp >>> >>> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" >>> pageEncoding="ISO-8859-1"%> >>> >>> >>> >>> >>> Insert title here >>> >>> >>> Client time : Click >>> >>> >>> >>> and a servlet that can take the client time (Hoping to :-) ) which is >>> mapped to 'clienttime.htm' >>> >>> protected void doGet(HttpServletRequest request, >>> HttpServletResponse response) throws ServletException, IOException { >>> response.setContentType("text/plain"); >>> long time = request.getDateHeader("Date"); // Hoping to >>> get the client date. >>> PrintWriter out = response.getWriter(); >>> out.println("Server time " + new Date()); >>> out.println("Client time (long) " + time); >>> out.println("Client time " + new Date(time)); >>> } >>> >>> >>> Is there any way to do this (get the client time from the request) ? >>> Or Am I trying to do a dumb thing ? ;) >>> >>> Thanks & Regards >>> Vinu >>> >>> >>> >>> >>> Shinya Koizumi wrote: >>> >>>> Vinu >>>> Yeah, you are right about it, I can't get getDateHeader working. >>>> >>>> For the solution one, I have setup like this for jsp and worked. >>>> >>>> <%@ page session="false" %> >>>> >>>> >>>> >>>> <%= application.getServerInfo() %> >>>> >>>> >>>> Current Time: >>>> <% >>>> out.println(""); >>>> out.println(""); >>>> %> >>>> >>>> >>>> >>>> SK >>>> ----- Original Message ----- From: "Vinu Varghese" >>>> To: "Tomcat Users List" >>>> Sent: Tuesday, July 11, 2006 1:24 AM >>>> Subject: Re: Getting the date/time from the client >>>> >>>> >>>> >>>>> Thanks SK, >>>>> >>>>> I tried the second solution , but request.getDateHeader("Date") >>>>> returns -1 . >>>>> >>>>> Also I didn't understand the first solution ( embed a javascript), >>>>> Can u >>>>> pls elaborate that. >>>>> >>>>> Thanks and regards >>>>> Vinu >>>>> >>>>> Shinya Koizumi wrote: >>>>> >>>>>> One is to embed javascript in the output >>>>>> >>>>>> out.println("JavaScriptExample"); >>>>>> out.println(""); >>>>>> out.println(""); >>>>>> >>>>>> >>>>>> The other solution is to get it from the request header. >>>>>> >>>>>> protected void doGet(HttpServletRequest request, HttpServletResponse >>>>>> response) >>>>>> throws ServletException, IOException { >>>>>> long l = request.getDateHeader("Date"); >>>>>> Date d = new Date(l); >>>>>> System.out.println(d); >>>>>> } >>>>>> >>>>>> SK >>>>>> ----- Original Message ----- From: "Vinu Varghese" >>>>>> To: "Tomcat Users List" >>>>>> Sent: Tuesday, July 11, 2006 12:51 AM >>>>>> Subject: Getting the date/time from the client >>>>>> >>>>>> >>>>>> >>>>>>> Hi All, >>>>>>> >>>>>>> I am doing a project in jsp/servlet and tomcat, which requires to >>>>>>> take >>>>>>> the client date/time (ie the time of the machine the browser is >>>>>>> running). Is there any way to accomplish this ? >>>>>>> >>>>>>> Thanks & regards >>>>>>> Vinu >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> ........................................ >>>>>>> >>>>>>> Vinu Varghese >>>>>>> vinu@x-minds.org >>>>>>> www.x-minds.org >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To start a new topic, e-mail: users@tomcat.apache.org >>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >>>>>> For additional commands, e-mail: users-help@tomcat.apache.org >>>>>> >>>>>> >>>>>> >>>>>> >>>>> -- >>>>> ........................................ >>>>> >>>>> Vinu Varghese >>>>> vinu@x-minds.org >>>>> www.x-minds.org >>>>> >>>>> >>>>> >>>> >>>> --------------------------------------------------------------------- >>>> To start a new topic, e-mail: users@tomcat.apache.org >>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >>>> For additional commands, e-mail: users-help@tomcat.apache.org >>>> >>>> >>>> >>>> >> >> --------------------------------------------------------------------- >> To start a new topic, e-mail: users@tomcat.apache.org >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >> For additional commands, e-mail: users-help@tomcat.apache.org >> >> >> >> > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > > > -- ........................................ Vinu Varghese vinu@x-minds.org www.x-minds.org --------------070005080206070505080103--