473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Are JSP files valid in any HTML version?


Hi,

Is there anyway to write JSP files as valid HTML of any sort. What I
want to know is if JSP files are some sort of valid XML with a DTD
that will check contents. Perhaps JSP files are valid XHTML documents?

Any pointers would be appreciated. Searching the web seems to be
leading me nowhere quickly.

Cheers!
Shyamal
Jul 17 '05 #1
4 2854
There is something in the JSP standard about an XML representation for
JSP pages (see http://java.sun.com/products/jsp/download.html#specs),
but JSP pages are NEITHER XML nor HTML. To illustrate why, consider
the generation of an img tag with the name of the image file coming
from a call to some method on some object:

<img src="<%=picture.getFileName()%>" alt="generated picture">

How could you write this substitution in well-formed xhtml?

That said, I think the relevant question isn't so much whether JSP (or
its competitors, ASP, PHP, ColdFusion, etc.) are valid html, xml or
xhtml. It really is, can they be used to generate conforming valid
xhtml and/or html. If that is relevant, then what you may want to do
is carefully write your JSP so that it constructs a page which is both
valid xhtml (and therefore valid xml) and at the same time, valid
html. Go to the www.w3c.org site, and look up the specification for
xhtml. There is a discussion in that document on how to write a page
that fills this requirement. Of course, that discussion is based on a
static view. You have to build a JSP whose output conforms to those
guidelines.

Cheers!
- Jerry Oberle
Jul 17 '05 #2
On Fri, 25 Jul 2003 20:05:24 -0700, Gerard Oberle wrote:
There is something in the JSP standard about an XML representation for
JSP pages (see http://java.sun.com/products/jsp/download.html#specs),
but JSP pages are NEITHER XML nor HTML. To illustrate why, consider the
generation of an img tag with the name of the image file coming from a
call to some method on some object:

<img src="<%=picture.getFileName()%>" alt="generated picture">

How could you write this substitution in well-formed xhtml?

That said, I think the relevant question isn't so much whether JSP (or
its competitors, ASP, PHP, ColdFusion, etc.) are valid html, xml or
xhtml. It really is, can they be used to generate conforming valid
xhtml and/or html. If that is relevant, then what you may want to do is
carefully write your JSP so that it constructs a page which is both
valid xhtml (and therefore valid xml) and at the same time, valid html.
Go to the www.w3c.org site, and look up the specification for xhtml.
There is a discussion in that document on how to write a page that fills
this requirement. Of course, that discussion is based on a static view.
You have to build a JSP whose output conforms to those guidelines.


Excellent advice. I just want to add the recommendation to submit the HTML
generated by the JSP to http://validator.w3c.org. Hint: download the Opera
browser. If you use Opera to test your page, just bring up your JSP and
hit Shift+Ctrl+V (on Windows or Linux; Opera on other operating systems
might use different key combinations), and it will automatically go to
this validator site.

By the way, the validator site also has a link to a similar CSS validator.

Do be aware that it is not always possible to write 100% W3C compliant
HTML. One of the most troublesome problems is the marginwidth= and
marginheight= attribute in the <body> tag; they are illegal in compliant
HTML, but the only way to achieve the desired effect on some versions of
IE and Netscape.

--
Keep American Families united! Support H.R. 539 and H.R. 832
For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml

Jul 17 '05 #3
JSP files are NOT XML-compliant, so there is no DTD for validation. Even if
you include your JSP scriptlets, expressions, and declarations in an
XHTML-formatted file, the JSP tags themselves do not conform to XML syntax.
The only way to get what you want is to use JSP bean tags only (like
jsp:useBean), and put them in an XHTML-formatted file.

"Shyamal Prasad" <sh************@ericsson.com> wrote in message
news:yz*************@ericsson.com...

Hi,

Is there anyway to write JSP files as valid HTML of any sort. What I
want to know is if JSP files are some sort of valid XML with a DTD
that will check contents. Perhaps JSP files are valid XHTML documents?

Any pointers would be appreciated. Searching the web seems to be
leading me nowhere quickly.

Cheers!
Shyamal

Jul 17 '05 #4
"Jerry" == goberle <go*****@hotmail.com> writes:

Jerry> That said, I think the relevant question isn't so much
Jerry> whether JSP (or its competitors, ASP, PHP, ColdFusion,
Jerry> etc.) are valid html, xml or xhtml.

Thanks to everyone for responses.

Incidentally, the relevant question actually actually was about the
possiblity of writing JSP files as DTD validated documents.

I write my xml/html files with a DTD aware editor, and I love being
able to point and click to add tags/attributes, and validate structure
with simple keystrokes. I was hoping to be able to train my editor
(xemacs with PSGML) to learn how to write JSP for Struts so I don't
have to keep looking up all the struts tags and so on (a concept that
works great, for example, with ant build files and plain old
HTML/XHTML).

As it turns out the answer seems to be pretty much that I can't do
this even when writing JSP files in the XML format because of
limitations when it comes to DTD validation with namespaces in
use. Not being able to validate mark up is something I am not used
to. So for now my ant build files invoke jasper and compile.....not
quite what I want, but close.....;-)

Cheers!
Shyamal

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: | last post by:
Although this question does not belong in here, I hope someone help, as I do not know where to send it, but someone here might have come acros similar problem: Some of JPG files sitting in the...
0
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
1
by: teddy311 | last post by:
Hello group, Why, when I execute the c# code on the xhtml validate file, the program insert a couple of hooks at the end of this line ? ....DTD/xhtml1-transitional.dtd"> _The c# code :_ ...
5
by: Bas Hendriks | last post by:
Has anyone any idea how asp.net find it's files back after compiling them to the temporary asp.net directory? I found on numerous webpages that the directorynames are chosen random but cannot find...
4
by: junky_fellow | last post by:
Hi, Is any one aware of some link that has the grammar files (yacc and lex files) for command interpreter like shell ? thanks a lot for any pointers ....
13
by: anil.rita | last post by:
When the user chooses an AV file to play, based upon the type of file, I want to use the default installed media player to play it. I am wondering if this is a good way - any alternatives,...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
5
by: Doogie | last post by:
Can anoyne tell me why this VBScript will create the file to Excel just fine, but the Excel file will not open up? I am saving it as a xlsx file instead of an xls one and I have the new version of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.