473,672 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2876
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*****@hotmai l.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
3037
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 same folder show up OK on an HTML page, while the other do not as if they are not there or their name is misspelt. Tried low-upper case in an ASP page, and in the files names - same result Then I noticed that the same files do not show up in the...
0
3627
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: "Specified cast is not valid." The only thing i put there was a "test this." inside the form. What might be the problem here? Thanks in advance. The Exception:
1
2043
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 :_ using System;
5
3850
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 how asp.net find's it's compiled files when asking for the same webpage which was complied before. -- Bas Hendriks Technical Specialist PinkRoccade
4
2794
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
4872
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, suggestions or improvements? if( wmv file) document.write("<OBJECT id=Player classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 height="354" width="479">
21
34392
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
221
367451
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 needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
5
48997
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 Excel on my machine and have opened other Excel files with that extension but this one I get the following error: "Excel cannot open the file 'Test.xlsx' because the file format or file extension is not valid. Verify that the file has not...
0
8945
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8847
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8643
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7476
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6255
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4242
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2840
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1839
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.