You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by benshort <be...@benshort.co.uk> on 2006/09/05 12:29:59 UTC

HTTP 304 - IF_MODIFIED_SINCE

Hi, 

How do I get the IF_MODIFIED_SINCE header from the HttpServletRequest
object?

When I use the HttpServletRequest.getHeaderNames() method and iterate
through the enumeration I get the following headers only.

accept
referer
accept-language
accept-encoding
user-agent
host
connection
cookie

Thanks 

Ben



-- 
View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6149505
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
ben short wrote:
> Yes you are right, I am trying not to serve resources again if they
> havent changed. From what I have read I need to set the Last-Modified
> header on the HttpServletResponse. The client will then send a
> If-Modified-Since request header the next time it needs that resource.
> I can then send HTTP Error 304 - Not modified, in return and all will
> be well.
>
> Again, thanks for your help.

Good to hear that it works for you.

Regards
  mks

---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by ben short <be...@benshort.co.uk>.
Ok,

I admit I was a bit fast going to the mailing list and I should of
done more research.

Yes you are right, I am trying not to serve resources again if they
havent changed. From what I have read I need to set the Last-Modified
header on the HttpServletResponse. The client will then send a
If-Modified-Since request header the next time it needs that resource.
I can then send HTTP Error 304 - Not modified, in return and all will
be well.

Again, thanks for your help.

Ben

On 9/5/06, Markus Schönhaber <ma...@schoenhaber.de> wrote:
> ben short wrote:
> > Im using Tomcat 5.5.17. I assumed that my browser would send the
> > If-Modified-Since Request-Header and have tried your jsp page and it
> > does.
>
> OK, this shows three things:
> 1. It's much less helpful to assume things than to find out for sure. If
> you're interested in the exact request your browser generates, there are a
> couple of ways get that information. For example: the LiveHTTPHeaders
> extension for firefox, something similar for IE, tools like Wireshark (The
> Application Formerly Known As Ethereal), the HTTP monitors NetBeans and the
> WTP for eclipse provide.
> 2. The JSP I posted causes Firefox and IE to send If-Modified-Since headers on
> the second request.
> 3. The answer to your original question "How do I access the If-Modified-Since
> header field" is "like you would do for any other header field".
>
> OTOH, from what you write about your servlet, I get the impression that your
> real problem is the following: "How do I avoid to serve ressources again
> which haven't changed since the last time the client accessed them?".
> If you want to decide whether or not the client has already requested the
> actual version of the ressource by using the If-Modified-Since header field,
> you'll have to find out what causes the clients to send such a header in the
> first place. RFC 2616 might provide some hints.
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> 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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
ben short wrote:
> Im using Tomcat 5.5.17. I assumed that my browser would send the
> If-Modified-Since Request-Header and have tried your jsp page and it
> does.

OK, this shows three things:
1. It's much less helpful to assume things than to find out for sure. If 
you're interested in the exact request your browser generates, there are a 
couple of ways get that information. For example: the LiveHTTPHeaders 
extension for firefox, something similar for IE, tools like Wireshark (The 
Application Formerly Known As Ethereal), the HTTP monitors NetBeans and the 
WTP for eclipse provide.
2. The JSP I posted causes Firefox and IE to send If-Modified-Since headers on 
the second request.
3. The answer to your original question "How do I access the If-Modified-Since 
header field" is "like you would do for any other header field".

OTOH, from what you write about your servlet, I get the impression that your 
real problem is the following: "How do I avoid to serve ressources again 
which haven't changed since the last time the client accessed them?".
If you want to decide whether or not the client has already requested the 
actual version of the ressource by using the If-Modified-Since header field, 
you'll have to find out what causes the clients to send such a header in the 
first place. RFC 2616 might provide some hints.

Regards
  mks

---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by ben short <be...@benshort.co.uk>.
Markus,

I have fixed the problem. I needed to set the contenttype and the
contentlength on the HttpServletResponse. Now i see the
if-modified-sice header on the second request.

Thanks for your input.

Regards

Ben

On 9/5/06, ben short <be...@benshort.co.uk> wrote:
> Markus,
>
> Im using Tomcat 5.5.17. I assumed that my browser would send the
> If-Modified-Since Request-Header and have tried your jsp page and it
> does.
>
> What I am doing is serving images from a database.
>
> Here is what I am doing in my spring controller...
>
> protected ModelAndView handleRequestInternal(HttpServletRequest
> httpServletRequest, HttpServletResponse httpServletResponse) throws
> Exception
>         {
>         Enumeration headers = httpServletRequest.getHeaderNames();
>
>         while ( headers.hasMoreElements())
>             {
>             String header = (String)headers.nextElement();
>
>             System.out.println( header + " : " +
> httpServletRequest.getHeader(header) );
>             }
>
>         final String url = httpServletRequest.getRequestURI();
>
>         final String imageName =
> url.substring(url.lastIndexOf("/")+1).toLowerCase();
>
>         Long imageId = Long.parseLong(imageName.substring(0,
> imageName.lastIndexOf(".")));
>
>         mIImageRepository.streamImage(imageId,
> httpServletResponse.getOutputStream());
>
>         httpServletResponse.setDateHeader("Last-Modified", new
> Date().getTime());
>
>         return null;
>         }
>
> This is the output i get the first time the page is called...
>
> host : 192.168.6.194:8080
> user-agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
> accept : image/png,*/*;q=0.5
> accept-language : en-us,en;q=0.5
> accept-encoding : gzip,deflate
> accept-charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
> keep-alive : 300
> connection : keep-alive
> referer : http://192.168.6.194:8080/catalog-1.0-SNAPSHOT/admin/editCategory.html?categoryId=1
> cookie : JSESSIONID=AB7DD26B34FCAEA604B904B275C03BAD
>
> And this is the output i get on the next call..
>
> host : 192.168.6.194:8080
> user-agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
> rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
> accept : image/png,*/*;q=0.5
> accept-language : en-us,en;q=0.5
> accept-encoding : gzip,deflate
> accept-charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
> keep-alive : 300
> connection : keep-alive
> referer : http://192.168.6.194:8080/catalog-1.0-SNAPSHOT/admin/editCategory.html?categoryId=1
> cookie : JSESSIONID=AB7DD26B34FCAEA604B904B275C03BAD
> cache-control : max-age=0
>
> Regards
>
> Ben
>
>
>
>
> On 9/5/06, Markus Sch�nhaber <ma...@schoenhaber.de> wrote:
> > ben short wrote:
> > > I have tried with firefox and ie6. May i ask what you are using?
> >
> > Firefox.
> > May I ask what you are using (i. e. Tomcat version)?
> >
> > You didn't answer my question: Does your browser send an If-Modified-Since
> > Request-Header?
> >
> > On Tomcat 5.5.17 calling this JSP *twice* will cause IE 6 and FF 1.5.0.6 to
> > send an If-Modified-Since header line on the second attempt. And the JSP will
> > display it.
> >
> > ---------- snip ----------
> >
> > <%@page contentType="text/html"%>
> > <%@page pageEncoding="UTF-8" session="false" import="java.util.*"%>
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> >    "http://www.w3.org/TR/html4/loose.dtd">
> >
> > <html>
> >     <head>
> >         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> >         <title>Request Headers</title>
> >     </head>
> >     <body>
> >         <h1>Request Headers</h1>
> >         <table>
> >             <tr>
> >                 <th>Header Name</th><th>Header Value</th>
> >             </tr>
> >             <%
> >                 response.addDateHeader("Last-Modified", new Date().getTime());
> >                 for(Enumeration headerNames = request.getHeaderNames();
> > headerNames.hasMoreElements();)
> >                 {
> >                     String headerName = (String) headerNames.nextElement();
> >                     String headerValue = request.getHeader(headerName);
> >             %>
> >             <tr>
> >                 <td><%= headerName %></td>
> >                 <td><%= headerValue %></td>
> >             </tr>
> >             <%
> >                 }
> >             %>
> >         </table>
> >     </body>
> > </html>
> >
> > ---------- snap ----------
> >
> > Regards
> >   mks
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>

Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Luke McLean <lu...@boundless.co.nz>.
Thanks Ben, 

I can follow that logic.  I have also found the imageDB sample app in the
Spring distro.  I am allowing people to upload an image then resizing it
into a Small, Medium and Large version (I figure it is better to resize and
store rather than resize on every use) however I have saved my images to the
database as bytea (byte[]) not BLOBs as per the sample app.  I have three
different resized images and I can use parameters to select the correct
image size to show.  I'm new to all this though and my learning curve is
still expotential!

I see that you refer to a method 'getData' on your image object,

1) how do you store you image data, and
2) what does the getData method look like? (do I need to do anthing other
than 'return data;'

Thanks for all this (I'm sooo close now!)

Luke, from New Zealand.


benshort wrote:
> 
> ...
> httpServletResponse.getOutputStream().write(image.getData());
> ...
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6219133
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by get_sathiya <ge...@yahoo.com>.

 hi  i red the complete conversation .. Actually i have also the same
problem with javascript files .. 
 Is it possible to  load the javascript files only if it is modified ... 
 Please help me ..    I willbe   greatful to you ..

   with regards
     sathiya 

Martin Gainty wrote:
> 
> Good Morning Luke-
> 
> If it runs on Tomcat then by all means copy the list..theres a good
> possibility someone has a solution that will work
> 
> Thanks,
> Martin --
> *********************************************************************
> This email message and any files transmitted with it contain confidential
> information intended only for the person(s) to whom this email message is
> addressed.  If you have received this email message in error, please
> notify
> the sender immediately by telephone or email and destroy the original
> message without making a copy.  Thank you.
> 
> 
> 
> ----- Original Message ----- 
> From: "Luke McLean" <lu...@boundless.co.nz>
> To: <us...@tomcat.apache.org>
> Sent: Friday, September 08, 2006 9:02 PM
> Subject: Re: HTTP 304 - IF_MODIFIED_SINCE
> 
> 
>> 
>> Oops, sorry everyone. I didn't realise that this was going out to the
>> whole
>> list!  
>> 
>> I'f you could contact me directly please Ben then I can avoid boring
>> everyone with this topic.
>> 
>> luke dot mclean at boundless dot co dot nz
>> 
>> Thanks comma
>> Not Luke (because he is embarrassed so an elf mysteriously wrote this in
>> his
>> absence).
>> 
>> 
>> benshort wrote:
>>> 
>>> Hi Luke,
>>> 
>>> This is a litte off topic for the Tomcat usergroup but here you go.
>>> 
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6219200
>> Sent from the Tomcat - User forum at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
>>
> 

-- 
View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6266993
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Luke-

If it runs on Tomcat then by all means copy the list..theres a good possibility someone has a solution that will work

Thanks,
Martin --
*********************************************************************
This email message and any files transmitted with it contain confidential
information intended only for the person(s) to whom this email message is
addressed.  If you have received this email message in error, please notify
the sender immediately by telephone or email and destroy the original
message without making a copy.  Thank you.



----- Original Message ----- 
From: "Luke McLean" <lu...@boundless.co.nz>
To: <us...@tomcat.apache.org>
Sent: Friday, September 08, 2006 9:02 PM
Subject: Re: HTTP 304 - IF_MODIFIED_SINCE


> 
> Oops, sorry everyone. I didn't realise that this was going out to the whole
> list!  
> 
> I'f you could contact me directly please Ben then I can avoid boring
> everyone with this topic.
> 
> luke dot mclean at boundless dot co dot nz
> 
> Thanks comma
> Not Luke (because he is embarrassed so an elf mysteriously wrote this in his
> absence).
> 
> 
> benshort wrote:
>> 
>> Hi Luke,
>> 
>> This is a litte off topic for the Tomcat usergroup but here you go.
>> 
>> 
>> 
> 
> -- 
> View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6219200
> Sent from the Tomcat - User forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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
> 
>

Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Luke McLean <lu...@boundless.co.nz>.
Oops, sorry everyone. I didn't realise that this was going out to the whole
list!  

I'f you could contact me directly please Ben then I can avoid boring
everyone with this topic.

luke dot mclean at boundless dot co dot nz

Thanks comma
Not Luke (because he is embarrassed so an elf mysteriously wrote this in his
absence).


benshort wrote:
> 
> Hi Luke,
> 
> This is a litte off topic for the Tomcat usergroup but here you go.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6219200
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by ben short <be...@benshort.co.uk>.
Hi Luke,

This is a litte off topic for the Tomcat usergroup but here you go.

I have added the following to my web.xml....

<servlet>
    <servlet-name>img</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>img</servlet-name>
    <url-pattern>/img/*</url-pattern>
</servlet-mapping>

My img-servlet.xml....

<bean id="imageController" class="com.benshort.catalog.web.ImageController">
    <property name="imageRepository"><ref bean="imageRepo"/></property>
</bean>

<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/*.*">imageController</prop>
        </props>
    </property>
</bean>

And my image controller....

public class ImageController extends AbstractController
    {
    private SimpleDateFormat mDateFormat = new SimpleDateFormat("EEE,
dd MMM yyyy HH:mm:ss zzz");

    private IImageRepository mIImageRepository;

    public void setImageRepository(IImageRepository ImageRepository)
        {
        mIImageRepository = ImageRepository;
        }

    protected ModelAndView handleRequestInternal(HttpServletRequest
httpServletRequest, HttpServletResponse httpServletResponse) throws
Exception
        {
        final String url = httpServletRequest.getRequestURI();

        final String imageName =
url.substring(url.lastIndexOf("/")+1).toLowerCase();

        Long imageId = Long.parseLong(imageName.substring(0,
imageName.lastIndexOf(".")));

        Image image = mIImageRepository.getImage(imageId);

        String ifModifiedSince =
httpServletRequest.getHeader("if-modified-since");

        if ( ifModifiedSince != null )
            {
            long modifiedDate = mDateFormat.parse(ifModifiedSince).getTime();

            if ( modifiedDate < image.getLastModified() )
                {

httpServletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                httpServletResponse.setContentLength(0);
                return null;
                }
            }

        httpServletResponse.setContentType(image.getMimeType());
        httpServletResponse.setContentLength(image.getLength());
        // ie seems not to see this header if its not in uppercase :S
        httpServletResponse.setDateHeader("LAST-MODIFIED",
image.getLastModified());
        httpServletResponse.getOutputStream().write(image.getData());
        httpServletResponse.flushBuffer();

        return null;
        }
    }

The controller needs a bit more wrk to handel bad urls etc, but its functional.

Give me a shout if you have any questions.

Regards

Ben


On 9/8/06, Luke McLean <lu...@boundless.co.nz> wrote:
>
> Hi Ben,  I'm starting out to do exactly the same thing and the web is quite
> sketchy on how to do it with Spring.  Would you mind posting or sending the
> controller code that you use to return the image please.  I would be very
> greatful.
>
> Thanks,
> Luke.
>
>
> benshort wrote:
> >
> > What I am doing is serving images from a database.
> >
> >
>
> --
> View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6203229
> Sent from the Tomcat - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Luke McLean <lu...@boundless.co.nz>.
Hi Ben,  I'm starting out to do exactly the same thing and the web is quite
sketchy on how to do it with Spring.  Would you mind posting or sending the
controller code that you use to return the image please.  I would be very
greatful.

Thanks,
Luke.


benshort wrote:
> 
> What I am doing is serving images from a database.
> 
> 

-- 
View this message in context: http://www.nabble.com/HTTP-304---IF_MODIFIED_SINCE-tf2220040.html#a6203229
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by ben short <be...@benshort.co.uk>.
Markus,

Im using Tomcat 5.5.17. I assumed that my browser would send the
If-Modified-Since Request-Header and have tried your jsp page and it
does.

What I am doing is serving images from a database.

Here is what I am doing in my spring controller...

protected ModelAndView handleRequestInternal(HttpServletRequest
httpServletRequest, HttpServletResponse httpServletResponse) throws
Exception
        {
        Enumeration headers = httpServletRequest.getHeaderNames();

        while ( headers.hasMoreElements())
            {
            String header = (String)headers.nextElement();

            System.out.println( header + " : " +
httpServletRequest.getHeader(header) );
            }

        final String url = httpServletRequest.getRequestURI();

        final String imageName =
url.substring(url.lastIndexOf("/")+1).toLowerCase();

        Long imageId = Long.parseLong(imageName.substring(0,
imageName.lastIndexOf(".")));

        mIImageRepository.streamImage(imageId,
httpServletResponse.getOutputStream());

        httpServletResponse.setDateHeader("Last-Modified", new
Date().getTime());

        return null;
        }

This is the output i get the first time the page is called...

host : 192.168.6.194:8080
user-agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
accept : image/png,*/*;q=0.5
accept-language : en-us,en;q=0.5
accept-encoding : gzip,deflate
accept-charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive : 300
connection : keep-alive
referer : http://192.168.6.194:8080/catalog-1.0-SNAPSHOT/admin/editCategory.html?categoryId=1
cookie : JSESSIONID=AB7DD26B34FCAEA604B904B275C03BAD

And this is the output i get on the next call..

host : 192.168.6.194:8080
user-agent : Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6
accept : image/png,*/*;q=0.5
accept-language : en-us,en;q=0.5
accept-encoding : gzip,deflate
accept-charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
keep-alive : 300
connection : keep-alive
referer : http://192.168.6.194:8080/catalog-1.0-SNAPSHOT/admin/editCategory.html?categoryId=1
cookie : JSESSIONID=AB7DD26B34FCAEA604B904B275C03BAD
cache-control : max-age=0

Regards

Ben




On 9/5/06, Markus Schönhaber <ma...@schoenhaber.de> wrote:
> ben short wrote:
> > I have tried with firefox and ie6. May i ask what you are using?
>
> Firefox.
> May I ask what you are using (i. e. Tomcat version)?
>
> You didn't answer my question: Does your browser send an If-Modified-Since
> Request-Header?
>
> On Tomcat 5.5.17 calling this JSP *twice* will cause IE 6 and FF 1.5.0.6 to
> send an If-Modified-Since header line on the second attempt. And the JSP will
> display it.
>
> ---------- snip ----------
>
> <%@page contentType="text/html"%>
> <%@page pageEncoding="UTF-8" session="false" import="java.util.*"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>    "http://www.w3.org/TR/html4/loose.dtd">
>
> <html>
>     <head>
>         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
>         <title>Request Headers</title>
>     </head>
>     <body>
>         <h1>Request Headers</h1>
>         <table>
>             <tr>
>                 <th>Header Name</th><th>Header Value</th>
>             </tr>
>             <%
>                 response.addDateHeader("Last-Modified", new Date().getTime());
>                 for(Enumeration headerNames = request.getHeaderNames();
> headerNames.hasMoreElements();)
>                 {
>                     String headerName = (String) headerNames.nextElement();
>                     String headerValue = request.getHeader(headerName);
>             %>
>             <tr>
>                 <td><%= headerName %></td>
>                 <td><%= headerValue %></td>
>             </tr>
>             <%
>                 }
>             %>
>         </table>
>     </body>
> </html>
>
> ---------- snap ----------
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> 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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
ben short wrote:
> I have tried with firefox and ie6. May i ask what you are using?

Firefox.
May I ask what you are using (i. e. Tomcat version)?

You didn't answer my question: Does your browser send an If-Modified-Since 
Request-Header?

On Tomcat 5.5.17 calling this JSP *twice* will cause IE 6 and FF 1.5.0.6 to 
send an If-Modified-Since header line on the second attempt. And the JSP will 
display it.

---------- snip ----------

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" session="false" import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Request Headers</title>
    </head>
    <body>
        <h1>Request Headers</h1>
        <table>
            <tr>
                <th>Header Name</th><th>Header Value</th>
            </tr>
            <%
                response.addDateHeader("Last-Modified", new Date().getTime());
                for(Enumeration headerNames = request.getHeaderNames(); 
headerNames.hasMoreElements();)
                {
                    String headerName = (String) headerNames.nextElement();
                    String headerValue = request.getHeader(headerName);
            %>
            <tr>
                <td><%= headerName %></td>
                <td><%= headerValue %></td>
            </tr>
            <%
                }
            %>
        </table>
    </body>
</html>

---------- snap ----------

Regards
  mks

---------------------------------------------------------------------
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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by ben short <be...@benshort.co.uk>.
I have tried with firefox and ie6. May i ask what you are using?

Ben

On 9/5/06, Markus Schönhaber <ma...@schoenhaber.de> wrote:
> benshort wrote:
> > How do I get the IF_MODIFIED_SINCE header from the HttpServletRequest
> > object?
> >
> > When I use the HttpServletRequest.getHeaderNames() method and iterate
> > through the enumeration I get the following headers only.
> >
> > accept
> > referer
> > accept-language
> > accept-encoding
> > user-agent
> > host
> > connection
> > cookie
>
> Works for me. Are you sure your client does actually send an If-Modified-Since
> header line?
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> 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


Re: HTTP 304 - IF_MODIFIED_SINCE

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
benshort wrote:
> How do I get the IF_MODIFIED_SINCE header from the HttpServletRequest
> object?
>
> When I use the HttpServletRequest.getHeaderNames() method and iterate
> through the enumeration I get the following headers only.
>
> accept
> referer
> accept-language
> accept-encoding
> user-agent
> host
> connection
> cookie

Works for me. Are you sure your client does actually send an If-Modified-Since 
header line?

Regards
  mks

---------------------------------------------------------------------
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