Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when to use jsp xml syntax 1

Status
Not open for further replies.

patlv23

Programmer
May 23, 2002
31
PH
hi!

i'm new to jsp so this is probably a basic question.
I'm just wondering if the jsp xml syntax is something everyone should shift to, or is it a case to case basis?

thanks!
 
What do you mean by "jsp xml" syntax ?
 
sorry if i don't get the terms right. I think it's called jsp document or something. syntax so jsp conforms to xml. anyway:

old/standard jsp syntax:
<% ... >
xml syntax:
<jsp:xxx ... >
 
Oh, it hasn't really got anything to do with conforming to xml, or a dtd.

Your first example (<% %>) is called a scriptlet tag - here you can embed Java code to be compiled by the container (eg Tomcat). Some people say you shouldn't use scriptlets as they should be in their own classes, some don't.

The second &quot;xml syntax&quot; (standard tag library)(<jsp:useBean .../>) is another way of using Java components, but in a more &quot;html coder /scripter friendly way&quot; - and it is the *desired* form for some.

To be honest, there are times when using scriptlets makes sense, and times when they don't. For example, you don't want to connect to a databse using scriptlet tags, but you may want to control the colours of an html <table> rows using a simple scriptlet loop.

In my experience, you should aim to go for the second tag library option, unless it means going to extraordinary lengths to do something that could be done in 2 minutes in a scriptlet.

Hope this clears it up ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top