Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Tag Library

 
suri jagadish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am developing a web application which does not use the struts framework but i want to use the tag libraries that are provided by struts. like the html tags etc. can some body help me in providing the information about what are the jar files that i have to use.
 
Gayathri Chowduru
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jagadish,

You can do that in two ways. You can use any of the IDE that supports struts framework. Like MyEclipse, NetBeans etc.. Or else,

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

you can use these declarations in the jsp and to your project libraries, add the struts.jar file.

you can check a simple web application using struts with NetBeans IDE from below link..

http://www.netbeans.org/kb/50/quickstart-webapps-struts.html

Thanks,
Gayathri Chowduru.
 
suri jagadish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply. But i mentioned very clearly that i don't want to use the struts framework. i.e No Action Classes, no struts-config.xml nothing.
i only want to use the tag libraries. I had put the struts.jar in the WEB-INF/lib but iam not able to use those taglibs since it insists in the ActionMappings not found...
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you will be able to use Struts tags without Struts framework.I am not sure.
You can use JSTL.But JSTL doesn't support HTML tags.
 
Gayathri Chowduru
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gowher Naik, you are true... We can't use struts tags without struts framework..

Jagadish, if you need only the html tags, you can include in your jsp the below declaration.

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

This will work for the static presentations only.. If you need the actions for controls, you should use the struts framework.

For my understatnding of your requirement, this is the solution.

Thanks,
Gayathri Chowduru.
 
suri jagadish
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
what do you mean by static presentations only?
my requirement is that i need the html:select which automatically selects a particular value from the options, which we pass into the tag.
 
Gayathri Chowduru
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understood. I am giving you a simple example..Check it..

myExample.jsp
-------------

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<html:html>
<head>
<script type="text/javascript">
function getTheValue(){
var Index = document.myForm.user.selectedIndex;
var Value = document.myForm.user.options[Index].text;
alert(Value);
}
</script>
</head>
<body>
<form action="" name="myForm">
<html:select name="user" property="user" onchange="getTheValue()">
<html ption value="ibm">IBM</html ption>
<html ption value="lenovo">Lenovo</html ption>
</html:select>
</form>
</body>
</html:html>

run this jsp page and let me know whether this is your requirement or not.. :-)

Thanks,
Gayathri Chowduru.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suri,

What you are trying to do... use Struts html tags without using the rest of the Struts framework... is simply not possible. Here's why:
  • html:xxx tags must always be enclosed in an html:form stanza. The required action attribute of this tag must point to a Struts action. It cannot point to a servlet or JSP.
  • The property attribute of any html:xxx tag must correspond to a property on an ActionForm bean. The ActionForm bean must in turn be associated with an action class
  • Given these restrictions, I don't see any way of using the Struts html:xxx tags without using the rest of the Struts framework.
     
    suri jagadish
    Greenhorn
    Posts: 19
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Merrill,

    you are right i also came to know that it is not possible to use the struts html tags without the struts framework.

    Thanks for all of you who have answered....
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic