• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are page directives obsolete?

 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs used to start with a page directive like:


It seems to me that this syntax might be obsolete now, and the new best practice would be to use a simple doctype, like:


 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. They are not mutually exclusive.

Using the directive does not replace the use of the DOCTYPE for the resulting document. Remember, directives are server-side instructions, and while they may reflect in the response header (the content type for example), they do not become part of the document body.

By the way, I've never used that directive as those are the defaults.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. And the convention is:

<!DOCTYPE html>

if you want to be one of the cool kids.

 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I totally want to be one of the cool kids! I just hope we've settled on that DOCTYPE form now so I can continue to be a cool kid without sending continuous update requests to my decidedly middle-aged memory module.

A cursory examination of online JSP tutorials showed page directives and no DOCTYPE, so I was thinking that one replaced the other. I'd forgotten that page directives don't generate body content (cf. point 1, wrt memory module). That's a good reminder.

On review, it still seems like page directives would be more-or-less obsolete. Certainly, import and language are obsolete if you don't use scriptlets, and I know Bear's views are clear on that point! Having a JSP content type other than "text/html" seems unlikely too. No? Changing the charset might be useful, but static HTML pages seem to be able to specify this by various techniques. Couldn't JSPs just do the same? There are some other fine-grained controls dealing with sessions, buffers, concurrency, etc., but practically speaking, is anyone really using those?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:I totally want to be one of the cool kids! I just hope we've settled on that DOCTYPE form now so I can continue to be a cool kid without sending continuous update requests to my decidedly middle-aged memory module.

The skuttlebutt is that the simplified DOCTYPE is here to stay for all future HTML.

A cursory examination of online JSP tutorials showed page directives and no DOCTYPE, so I was thinking that one replaced the other.

Leaving the DOCTYPE off is a bad bad idea. It lets the browser pick whatever it likes. Whereas when the HTML5 DOCTYPE is used, there are distinct and defined behaviors that the browser must exhibit. HTML5 defines these behaviors to a much grater extent than HTML4.

I'd forgotten that page directives don't generate body content (cf. point 1, wrt memory module). That's a good reminder.

Don't feel bad. I know all about faulty memory modules. I live off PostIt Notes and my iPad. Without either, I'd be wandering the streets wondering what my name was.

On review, it still seems like page directives would be more-or-less obsolete.

As I've said, I've never used them as I never needed anything but the defaults.

Certainly, import and language are obsolete if you don't use scriptlets, and I know Bear's views are clear on that point!

Yes. Don't get me going!

Having a JSP content type other than "text/html" seems unlikely too. No?

Depends. I've used JSPs to generate JSON (before better libraries were available), plain text, XML, and even RTF. But I've never set the content type in the JSP itself.

practically speaking, is anyone really using those?

In my experience, the savvy handle any heavy lifting in the controller and try to keep the JSPs as dumb as possible. Works for me!
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, all clear now!

Btw, it's scuttlebutt, coming from the "scuttled butt" (a barrel with a hole punched through the bottom), which contained the fresh water supply for the crew on sailing ships. The sailors would stand around it sharing the shipboard gossip, just like office workers stand around water coolers today. I've always found that a refreshing reminder of the consistency of human behavior across different times and circumstances.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sayz youz!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic