• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

struts newbie needs help with autocompleter

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all. Im new to struts. I have been reading up on it for about 2 days now. I am trying to get an autocompleter to work from a list populated by a database call. I understand that I can set up a class that adds things to a list. I can handle the database call, no problem. The problem I have is all the config thats required in struts.
Im currently using struts 2.1.
I have the following in my JSP:
with of course the

I also have the following in a class :-


and here's where I think I am going wrong. I have the following in struts.xml:-

and the following in the web.xml:-


but I get the 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]"
when visiting my jsp page. So I added the following to the web.xml:-



and then I get a HTTP 404.

Can anyone help. It's frustrating getting started with struts. I get the ideas behind it but cant get anything to actually work.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Wa wrote:


Whoa, that's Struts 1. You'll want to take out all the Struts 1 stuff.

What libraries are you deploying?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does nobody have any ideas?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read EaseUp. It's 8:30 on a Saturday morning--the weekend.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies. Its 12.40 here. I forget that most of this forum's users are probably in the USA. I don't mean to be pushy.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:

Mark Wa wrote:


Whoa, that's Struts 1. You'll want to take out all the Struts 1 stuff.

What libraries are you deploying?



sorry didn't see your post.
I am using the struts 2.1 jars. I probably mixed up code from head first servlets&jsps as well as demos on the internet. My bad.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. That's Stripped out. Now I guess as i'm still getting a HTTP404 that the filter is not forwarding the request on
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The" Struts 2 jars doesn't help.

Please see TellTheDetails.

Is there anything in the startup log? (My guess right now is yes.) Do you have devMode turned on?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added all the jars that came with struts 2 as I am unsure of which I will be needing.

Server log? - yes there's this:- (but it always says this)


dev mode? no idea what that is.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot add an arbitrary collection of jars to a deployment, as each may introduce their own dependencies, or otherwise impact expected behavior. Stick to the minimum until you know what you're doing.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I just have :-

jstl-api-1.2.jar
jstl-impl-1.2.jar
spring-core-2.5.6.jar
spring-web-2.5.6.jar
struts2-core-2.1.8.1.jar
struts2-dojo-plugin-2.1.8.1.jar
struts2-spring-plugin-2.1.8.1.jar
xwork-core-2.1.6.jar

now it deploys fine when I deploy without the filter, but when I add the filter stuff into the web.xml I get an error. My guess is that the jar containing the required class is not there? - googling it but not having much luck.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't deploy the Spring plugin without deploying Spring.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. forgetting the spring jars the problem is still the same

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]


 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you calling a JSP page with Struts 2 tags directly instead of going through an action?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes probably. I am typing the URL of the jsp page with the tags on.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As the error states, you can't.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but would



not run everything through the filter?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes. That does not mean the filter *does* something with every request.

Seriously; why would I lie?
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Yes. That does not mean the filter *does* something with every request.

Seriously; why would I lie?



OK now i'm confused. Think I need to find a comprehensive struts tutorial. Any suggestions?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about the Struts documentation wiki?

What's confusing? A filter mapped to "/*" will intercept every request. Filters can ignore requests and simply pass it on to the next filter in the chain.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah I understand the filters bit, just not sure how I should be accessing my jsp
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Through an action.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and that would be?

http://localhost:8080/mywebappname/autocompleter.action ?
http://localhost:8080/mywebappname/autocompleter ?

nothing works
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ItDoesntWorkIsUseless.

I don't know what the app context is you're deploying to; if it's "mywebapname" as you imply then either should work with Struts 2.1.

I'd encourage you to turn on devMode, set the log level to debug, and look for startup errors.
 
Mark Wa
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
wow you have tips pages for everything!

It works (well not correctly, but IT WORKS!)

I changed both of these from false to true


Nearly a whole day, but Its solved!

Thanks David for your help. Its much appreciated.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DynamicMethodInvocation is something else entirely and would not have caused it to start working; it's only for using "action!method" URL patterns. DevMode just jacks up some reporting. If it started working after those changes then something else had been corrected, but not deployed.

No problem--it can be a frustrating process wrapping your head around something new sometimes.
 
I'm full of tinier men! And a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic