Applet or servlet

F

fasisi

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

Andrea Francia

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

GArlington

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

Roedy Green

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

Roedy Green

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>";
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top