1

I am using Struts 2.1.8.1. I want to use tags, supplied by struts, im my jsp pages. e.g

<%@ taglib prefix="html" uri="/struts-tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <title>Transfer Program - Login</title>
   </head>
   <body>
       <html:form action="/loginaction.do" method="post">
           Username:<html:text name="username"></html:text>
       </html:form>
   </body>
</html>

But when I run the above jsp page, I got the following error:

The Struts dispatcher cannot be found.  This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
Amit
  • 33,847
  • 91
  • 226
  • 299

1 Answers1

5

You cannot use Struts 2 tags with Struts 1. Struts 2 is from the WebWorks project and it's not backward compatible with Struts 1.

  • Struts 1 works with Actions
  • Struts 2 works with filters and dispatchers.

Hence why you get this:

The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]

Get the Struts 1 taglibs and replace the Struts 2 taglibs.

Follow my answer from your question here: Struts - Taglib directive in a JSP page for .tld provided by Struts

Edit A good tutorial site:

Community
  • 1
  • 1
Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • That's correct. Maybe you can recommend him a clear and concise Struts tutorial/guide. Judging his question history learns me that he has a very hard time in getting the Struts stuff right :) – BalusC Mar 07 '10 at 06:11
  • @Balcus @Elite Actually I learnt Struts recently from books provided by `Sun Microsystems` and tried to use it in one of my projects. The version of `struts` is not mentioned in the book and that's why I downloaded the latest version of struts to work with... but now I think that as the book refers to `Action`, it is about `struts 1`... (correct me if I am wrong)... – Amit Mar 07 '10 at 06:19
  • Geez...Struts have millions of tutorials out there (since probably it's inception). I'll try and find something that'll help him but a good start is to go to Struts homepage itself (http://struts.apache.org/) – Buhake Sindi Mar 07 '10 at 06:23
  • 1
    @Yatendra, Sun is good, but Struts is NOT Sun. Yes, Actions are for Struts 1. Look at my edited post, there's wonderful sites who posted tutorial on Struts. – Buhake Sindi Mar 07 '10 at 06:27
  • 2
    Roseindia.net :/ Their Java/JSP/JSTL/Servlet/JDBC/JSF tutorials are **horrible**. It's one and all bad practice. I don't do Struts, so I can't tell if their Struts tutorials are "right", but the whole site gives me a bad feeling: http://balusc.blogspot.com/2008/06/what-is-it-with-roseindia.html – BalusC Mar 07 '10 at 06:31
  • LOL @BalusC, I know what you mean. They usually have the right idea of doing things (even though I don't agree with how they implement certain things). I wanted Yatendra to see the "setup" of Struts and the rest he'll have to do more research on. – Buhake Sindi Mar 07 '10 at 23:23