• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ask for examples!

 
Niu Xiuyuan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
who can give me some examples about setIntHeader() and setDateHeader() methods?
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Xiu,
no example, but a clear info copied from Marty Halls older Servlet book, which does not cover the newest specs, but which you can get for free from the Internet:
http://pdf.coreservlets.com/
The following is from chapter7, page 3. I think the book is good, especially didactically.
(for me they could have used overloading either, but so the name of Data Type is part of the method name.)
Hall: "
In addition to the general-purpose setHeader method, HttpServlet-Response
also has two specialized methods to set headers that contain dates
and integers:
• setDateHeader(String header, long milliseconds)
This method saves you the trouble of translating a Java date in
milliseconds since 1970 (as returned by
System.currentTimeMillis, Date.getTime, or
Calendar.getTimeInMillis) into a GMT time string.
• setIntHeader(String header, int headerValue)
This method spares you the minor inconvenience of converting
an int to a String before inserting it into a header."

Axel
[ January 10, 2002: Message edited by: Axel Janssen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic