Reputation: 7647
What is the difference between <s:select>
and <html:select>
tags? What is the purpose of having two different tags for same purpose of populating a drop down?
Upvotes: 0
Views: 533
Reputation: 1
Both tags have the same name but different namespaces defined by the tag prefix.
If you want to use some other tag library that has tags with names you have already in use then better define those tag libraries under different namespaces, so tag names doesn't clash to achieve the different behavior.
To make sure the tag names didn't clash better to use other tag libraries prefixed with different namespaces.
Upvotes: 0
Reputation: 50203
The <html:select>
and <html:something
tags are part of the Struts 1 taglibraries, specifically the tags-html library:
<%@taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<html:select ...>
Example of usage of Struts1's <html:select>
, while <s:select>
and <s:something
tags are part of the Struts 2 taglibraries,
specifically the struts-tags library:
<%@taglib prefix="s" uri="/struts-tags" %>
<s:select ...>
Example of usage of Struts2's <s:select>
EDIT
As @UmeshAwasthi made me notice, it may not be obvious that this is a Convention, not a code syntax;
this means that, if some crazy guy who doesn't like standards wants to invert the prefixes of the taglibraries, HE CAN, in the same way he can write Integer myDouble = new Integer();
... only the semantics are broken, the syntax is ok.
But, since I guess the doubts (the same I had years ago) that originated your question were due to the multiple occurrences of this two syntaxes (<html:
and <s:
) on the web, well, believe me, they always refer to the proper libraries (at least in online articles, maybe not always in some question here or on coderanch etc).
To sum it up, the Convention (not the Rule, just the rule) is:
html = Struts 1
s = Struts 2
c = JSTL
Upvotes: 0
Reputation: 23587
Well it dependents upon in what respect you are talking about and both above answer are correct in there own way.
There can be two aspects here
Generally all who have worked with Struts old version are well known about using html
as tag prefix and is very well explained by Andrea Ligios.
in general when we use Struts2 tag we use s as prefix but this is only a convention and you can use any convention (prefix) like <s:select>, <html:select>, <myprefix:select>
.
All you need to tell framework what prefix, you wan to use with the help of following line in you template file
<%@taglib prefix="prefix of you choice" uri="/struts-tags" %>
Though i am sure that you might have seen code at tow places with one represents old Strut and other represents Struts2 version.
Upvotes: 0
Reputation: 40318
No difference.It depends on the prefix
If you use this
<%@ taglib prefix="s" uri="/struts-tags" %>
then use
<s:select>
If you use this
<%@ taglib prefix="html" uri="/struts-tags" %>
<html:select>
then use
Upvotes: 1