Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic dateTime for an HTML page?

 
Ryan McClain
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just got this weird assignment:

"You have to write a servlet that generates an HTML page with the current date and time upon a GET request"

Weird part:
"Provide an init-param that can set the dateTime format" (what does that even mean?)

How am I supposed to provide any semantics in an init-param? Isn't it just a pure String?
How do I tell my serlvet which dateTime format it's supposed to take by giving it an init-param?

I don't understand.

Could anyone clarify this please?

Thanks
 
Julien Coe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the XML where you describe your servlets (web.xml) you can add some init-parameters to your servlet:



You can then get them in your servlet with the following code





About the date format, you can check here: Date Format


and use something like that:


 
Ryan McClain
Ranch Hand
Posts: 145
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It's working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic