• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2 wildcard matching issues

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having some issues with wildcard mapping. I wanted to catch all attempts to visit anything behind "/secure".



This works if I try to visit "/secure/anything/anything/etc" and I'm not logged in, I get directed to the login page as per my interceptor. However if I just logged in and I'm at "http://localhost:8080/Struts2NewChapter8/secure/admin-portfolio" and I click a link to "http://localhost:8080/Struts2NewChapter8/secure/update/update-account-form" I get errors that look like this:

Here's my simple intercept method if you're curious:

 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem happens I think at the call to .invoke() in my interceptor. If I print the action at this point it just says its of type ActionSupport. Then when invoke is called, there's that long stacktrace, and the result that gets returned is "success". However, then instead of trying to continue to where I was trying to go, I get a resource not found error. The resource exists, because I can access it, but I think the errors that are being thrown cause the problem.
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, ok, now I'm a little confused. I modified by intercept method by adding in this:



I think maybe there's a problem calling .invoke() for an URL that catches this interceptor but doesn't actually have an action to back it up. I figured that instead of calling invoke, I'd just return success. The error is gone BUT I still get resource unavailable. Probably I'm not supposed to do things like this so it doesn't work. Any thoughts?
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a little confused with the design of your application. A single Action handling all the requests starting with /secure. Are you doing this only to execute your interceptor (and redirect the request to the appropriate action since you are using {1} as result)?? You can easily add your interceptor to the default interceptor stack of your application. I'm sure your application would have two packages, one for normal actions and one for secure actions. You can add your interceptor to the interceptor stack of the secure package...
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To clarify, there are cases where I DON'T HAVE an action. For example, I may want to access a secure image upload form, but that's so simple that I don't need an action. However, I still want it to be secure. So I'm trying to intercept all accesses to "/secure" that DON'T HAVE an action. Normally they would just pass right through but I'm trying to get them intercepted. Obviously, if there was an action the interceptor would get triggered. And my wildcard matching worked, ie, all my navigations to places under "/secure" that don't have a backing action get intercepted now. However, when the .invoke method is called in the interceptor, it gives me all those errors. I thought maybe it was because, you can't call invoke if you don't have a backing action class, so I made one to act as just an empty class for all of the accesses to "/secure/etc." that don't have their own actions. This didn't work either. I'm still getting errors AND the resource is always unavailable.

I don't think what I'm doing is that advanced. I'm surprised no one has seen this before.
 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cross Post...
 
Pj Casaro
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, thanks for reminding me. I solved the issue. You shouldn't do wildcard matching on the namespace I suppose and just limit it to the action itself. Don't ask me why.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic