Applet or servlet

Discussion in 'Java' started by fasisi, Feb 11, 2008.

  1. fasisi

    fasisi Guest

    Hello,

    I have a website and I want, for example, the background image
    dynamically change every week. I will have the images on the hosting
    server. Should I use applet or servlet?


    Thank you,

    Fasisi

    NB: Is there good source to learn servlet other than Sun's tutorial?
    fasisi, Feb 11, 2008
    #1
    1. Advertising

  2. I can't use an applet to doing this.
    You can use any server side technologies that change the content sent
    over the time, such as jsp, servlet, or even PHP.
    Or you can use a client side technology (such as javascript) to request
    a different background image each week.
    Or you can simply use an automated ftp client that replaces the
    background image every week.

    I think the last mentioned solutions is the simplest one, but if you
    want solve the problem in order to learning something about java you can
    try to realize a solution based on servlets.

    I'm not able to recommend any book to you, may be you can find something
    useful in the O'reilly books.

    fasisi wrote:
    > Hello,
    >
    > I have a website and I want, for example, the background image
    > dynamically change every week. I will have the images on the hosting
    > server. Should I use applet or servlet?
    >
    >
    > Thank you,
    >
    > Fasisi
    >
    > NB: Is there good source to learn servlet other than Sun's tutorial?
    Andrea Francia, Feb 11, 2008
    #2
    1. Advertising

  3. fasisi

    GArlington Guest

    On Feb 11, 6:28 am, fasisi <> wrote:
    > Hello,
    >
    > I have a website and I want, for example, the background image
    > dynamically change every week. I will have the images on the hosting
    > server. Should I use applet or servlet?
    >
    > Thank you,
    >
    > Fasisi
    >
    > NB: Is there good source to learn servlet other than Sun's tutorial?


    If you want to change the background image as seldom as once a
    week(month/day) you can set a scheduled job which will change your web
    servers rewrite rule for your background image.
    If you want it done more often (on rotation basis) you are better of
    using some sort of server side script to generate the image (or image
    name) dynamically...
    GArlington, Feb 11, 2008
    #3
  4. fasisi

    Roedy Green Guest

    On Sun, 10 Feb 2008 22:28:33 -0800 (PST), fasisi
    <> wrote, quoted or indirectly quoted someone
    who said :

    >I have a website and I want, for example, the background image
    >dynamically change every week. I will have the images on the hosting
    >server. Should I use applet or servlet?


    You don't need either. Just change the file locally and upload. That
    is how I change the critter of the day on page
    http://mindprod.com/index.html

    Most people handle that with a Servlet. I handle it with static
    macros.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Feb 11, 2008
    #4
  5. fasisi

    Roedy Green Guest

    On Mon, 11 Feb 2008 03:11:16 -0800 (PST), GArlington
    <> wrote, quoted or indirectly quoted someone
    who said :

    >On Feb 11, 6:28 am, fasisi <> wrote:
    >> Hello,
    >>
    >> I have a website and I want, for example, the background image
    >> dynamically change every week. I will have the images on the hosting
    >> server. Should I use applet or servlet?
    >>
    >> Thank you,
    >>
    >> Fasisi
    >>
    >> NB: Is there good source to learn servlet other than Sun's tutorial?

    >
    >If you want to change the background image as seldom as once a
    >week(month/day) you can set a scheduled job which will change your web
    >servers rewrite rule for your background image.
    >If you want it done more often (on rotation basis) you are better of
    >using some sort of server side script to generate the image (or image
    >name) dynamically...


    see http://mindprod.com/jgloss/pseudorandom.html

    For how to get an integer you can use to select the image.

    You can xor in the name of the page (as hashCode), or today's date, as
    time divided by millis per day as the seed to make the selection
    depend on date or page, not changing every time.

    Here is the guts of one of my static macros that selects a daily quote
    for each page:

    /**
    * expand Quotation macro guts
    *
    * @param fileBeingProcessed file where macros are embedded.
    *
    * @return on of the choice strings, randomly chosen
    */
    private String expand( File fileBeingProcessed )
    {
    // use today as a seed so will generate same value for
    24-hours
    // using GMT elapsedTime. Flip will happen at midnight GMT or
    4 PM PST.
    // Reproducible every time we run this macro that day.
    // Xor in hashCode of filename to give a different quote to
    different pages.
    final Random wheel =
    new Random( fileBeingProcessed.getPath().hashCode()
    ^ ( System.currentTimeMillis() / ( 24
    * 60
    * 60
    * 1000
    ) ) );
    final String chosenQuote = QUOTATIONS[ wheel.nextInt(
    QUOTATIONS.length ) ];

    return "<blockquote>"
    + chosenQuote
    + "</blockquote>";
    }
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Feb 11, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Fish
    Replies:
    4
    Views:
    2,407
    Andy Fish
    Dec 17, 2003
  2. Sean Clarke
    Replies:
    1
    Views:
    1,882
    Sudsy
    Jan 7, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    1,989
    Jack Jia
    Apr 4, 2004
  4. chamikara
    Replies:
    1
    Views:
    49,836
  5. Tedy
    Replies:
    1
    Views:
    440
    Andrew Thompson
    Aug 4, 2005
Loading...

Share This Page