简体   繁体   中英

Read Browser/Client time from Http Servlet request header

是否可以在向servlet发出请求时读取浏览器(客户端计算机)的时间?

I don't believe so. Unfortunately the HTTP Date header is only sent for PUT or POST messages, and even then it's optional:

Clients SHOULD only send a Date header field in messages that include an entity-body, as in the case of the PUT and POST requests, and even then it is optional. A client without a clock MUST NOT send a Date header field in a request.

If you have control of the client, you could (perhaps) encode it as a separate experimental HTTP header. Or add it as a GET parameter etc.

You can use javascript and append the time to every request. Provided that javascript is enabled, you can add the following to your links:

link = link + "?date="+(new Date()).getTime()

You can do something similar, if you need timezone information. This question may help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM