File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Are page directives obsolete? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Are page directives obsolete?" Watch "Are page directives obsolete?" New topic
Author

Are page directives obsolete?

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

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

Joined: Jan 10, 2002
Posts: 61606
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

P.S. And the convention is:

<!DOCTYPE html>

if you want to be one of the cool kids.

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

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

Joined: Jan 10, 2002
Posts: 61606
    
  67

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

Joined: Oct 01, 2001
Posts: 2861
    
  11

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

Joined: Jan 10, 2002
Posts: 61606
    
  67

Sayz youz!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are page directives obsolete?