There's the simple HTML--these are simply sent from the server to the client. This includes <input> tags, <b> tags, etc.
Then there are JSP tags, like <c:if>, <fmt:...>, etc. These are interpreted on the server side before being sent to the client.
There are no issues with embedding JSP tags in HTML tags, since they're on different planes of existence. You cannot, however, use a JSP tag as an attribute value for another JSP tag.
A simple web search would have validated your approach.
Edward Winchester
Ranch Hand
Joined: Sep 16, 2009
Posts: 65
posted
0
David Newton wrote:There are two "levels" of tags in a JSP file.
There's the simple HTML--these are simply sent from the server to the client. This includes <input> tags, <b> tags, etc.
Then there are JSP tags, like <c:if>, <fmt:...>, etc. These are interpreted on the server side before being sent to the client.
There are no issues with embedding JSP tags in HTML tags, since they're on different planes of existence. You cannot, however, use a JSP tag as an attribute value for another JSP tag.
Thank you.
A simple web search would have validated your approach.
I did a lot of searching on the web before posting this query. I didn't find any page that validated my approach. There was examples using expression language in attributes. I only post on forums after searching on the web.
Ed
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
JSTL is cool. You may want to work through the 4-part introduction linked under "Resources" in the http://faq.javaranch.com/java/JspFaq to learn about all the things it can do.
Another way to look at it is to recognize that to a JSP, anything that's not a JSP element (JSP action, scriptlet, EL expression, etc) is simply template text to the JSP engine. The fact that HTML looks like tags is completely moot because the JSP just treats it as text without even looking at it.
Bear Bibeault wrote:Another way to look at it is to recognize that to a JSP, anything that's not a JSP element (JSP action, scriptlet, EL expression, etc) is simply template text to the JSP engine. The fact that HTML looks like tags is completely moot because the JSP just treats it as text without even looking at it.
Ahh, ok. I thought there might be some complex rules about some elements only being available in some contexts. I was looking at my problem from an XML/XHTML viewpoint where it just didn't look right. I guess JSP doesn't even have to be used with HTML hence the term "template text" to generically refer to the non-JSP stuff.
So there is no real context - just template text whose structure is unimportant (and there need be no structure at all) and JSP elements.
Feel like a penny has just dropped!
Edward Winchester
Ranch Hand
Joined: Sep 16, 2009
Posts: 65
posted
0
Ulf Dittmer wrote:JSTL is cool. You may want to work through the 4-part introduction linked under "Resources" in the http://faq.javaranch.com/java/JspFaq to learn about all the things it can do.
Edward Winchester wrote:So there is no real context - just template text whose structure is unimportant (and there need be no structure at all) and JSP elements.
Exactly. Whatever is not a JSP element could be random characters entered by letting an iguana walk over the keyboard as far as the JSP engine is concerned.
The HTML-ness of the generated page is important only to the browser when it receives the response.
Bear Bibeault wrote:Whatever is not a JSP element could be random characters entered by letting an iguana walk over the keyboard as far as the JSP engine is concerned.
That's actually quite close to how most HTML seems to be developed.
Bear Bibeault wrote:Whatever is not a JSP element could be random characters entered by letting an iguana walk over the keyboard as far as the JSP engine is concerned.
That's actually quite close to how most HTML seems to be developed.
Based upon what I've seen, it is certainly how most JavaScript is written.
I've never really understood why JavaScript is so abused and mis-understood. Except for a few glaring warts (I'm looking at you, this) I really, really like it, and it's quite capable.
Assuming that the OP's question has been adequately addressed (please let us know)...
In my opinion, while JavaScript is one of the world's most-used languages (due to its ubiquitousness on the web), it is the also the one least understood by most who use it.
It's actually quite an elegant and interesting language. I truly believe that most people who moan "I hate JavaScript", really don't understand the language, or are reacting to the browser DOM models (which are a complete mess), rather than to the language itself.
Edward Winchester
Ranch Hand
Joined: Sep 16, 2009
Posts: 65
posted
0
Bear Bibeault wrote:Assuming that the OP's question has been adequately addressed (please let us know)...
What you said about JSP elements and template text was very helpful. My worry/uncertainty has been lifted. Thanks.
Lukasz Ochmanski
Greenhorn
Joined: Aug 14, 2012
Posts: 1
posted
0
It is possible in JSP:
<jsp:attribute>
The jsp:attribute element allows you to define the value of a tag attribute in the body of an XML (HTML) element instead of in the value of an XML (HTML) attribute.
JSP Syntax
XML (HTML) Syntax
Same as JSP syntax.
Examples
The following template page uses jsp:attribute, which uses the output of fmt:message to set the value of the value attribute of tt:parameter: