另外在Tomcat的邮件列表中名为Christ写了一段很好的关于在搜索中使用jsessionid的问题:
> Is there anyway to create JSessionIDs per window rather than per browser?
> I am having the problem of when you open multiple tabs within
> a browser, and enter two simultaneous queries, the results returned are
> corrupted. Any suggestions? Thanks for the help.
I have an application that allows the user to perform searches and paginate through the results. Since the search really only needs to be performed once, pagination can be as simple as picking a segment of the results (stored in the session) and displayed on the screen.
I store the query that was performed as well as a "token" which is generated when the query is created. I place this token in all of the URLs on the page (most importantly, the ones involved with pagination).
If a request comes into the server including a token, I check the token against what I have in the session. If the tokens match, I skip the search. If they do not match, I re-run the search and re-set the token. Rinse, repeat.
In your case, you might want multiple simultaneous paginating queries, though I'm not exactly sure why. You could adopt a similar approach using a List of queries (using the same session key, I would imagine),
each with separate tokens for the windows.
The only problem with an implementation like this is that it is very hard to decide when you are "finished" with a query, and that it's okay to purge it from the session. That is left as an exercise for the reader
;)
Hope that helps,
-chris
手头要是没有装这个插件,可以使用Unix下的 wget 或 curl来查看服务器端返回的Response Header,缺点是无法查看提交网页时的Request Header。
回复删除jiad4701@urts96:~/> curl -I http://www.google.de
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=ISO-8859-1
Set-Cookie: PREF=ID=c5e3c4274641408f:TM=1176449716:LM=1176449716:S=RJ68RNVegADRq_w_; expires=Sun, 1 7-Jan-2038 19:14:07 GMT; path=/; domain=.google.de
Server: GWS/2.1
Content-Length: 0
Date: Fri, 13 Apr 2007 07:35:16 GMT
jiad4701@urts96:~/projects> wget -S --spider http://www.uni-trier.de
--09:38:31-- http://www.uni-trier.de/
=> `index.html'
Auflösen des Hostnamen »www.uni-trier.de«.... 136.199.8.62
Verbindungsaufbau zu www.uni-trier.de|136.199.8.62|:80... verbunden.
HTTP Anforderung gesendet, warte auf Antwort...
HTTP/1.1 200 OK
Date: Fri, 13 Apr 2007 07:38:31 GMT
Server: Apache/2.0.50 (Linux/SUSE)
Last-Modified: Mon, 02 Apr 2007 03:14:42 GMT
ETag: "71c18f-2693-9f4e0c80"
Accept-Ranges: bytes
Content-Length: 9875
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html
Länge: 9.875 (9.6K) [text/html]
200 OK