Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Struts 1.x and permanent GET parameter for every Action. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.x and permanent GET parameter for every Action." Watch "Struts 1.x and permanent GET parameter for every Action." New topic
Author

Struts 1.x and permanent GET parameter for every Action.

Lari Alpi
Greenhorn

Joined: Nov 18, 2009
Posts: 3
Hello all,

the problem is that I need to keep certain request parameter in the URL for every Action.

E.g:
/fooApp/something.do?db=foobar
/fooApp/blahblah.do?db=foobar

This 'static' parameter tells the webapp which database to use. HttpSession is out of the question because there's no certain "entrypoint"/login for the webapp.

Any ideas how to accomplish this or any alternative ideas?

Thanks,
- Lari
Lari Alpi
Greenhorn

Joined: Nov 18, 2009
Posts: 3
Lari Alpi wrote:
Any ideas how to accomplish this or any alternative ideas?


Or could somekind of URL rewrite be a possibility?

E.g:
/fooApp/dbname/something.do

- Lari
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Ugh.

In any case, I don't see how session is "out of the question"--just because there's no entry point doesn't mean that it can't be captured a single time then stored in session, perhaps using a filter or a custom request processor to put it back into the request if that's *really* necessary. I can't think of why it would be.

In any case, I'd look into a filter or a custom request processor.
Lari Alpi
Greenhorn

Joined: Nov 18, 2009
Posts: 3
David Newton wrote:Ugh.


Indeed. This is stupid, but gotta do.

David Newton wrote:
In any case, I don't see how session is "out of the question"--just because there's no entry point doesn't mean that it can't be captured a single time then stored in session,


Yes, you're right. In reality I'll put the parameter to HttpSession when first encountered but I need to keep it in the URL also. This is needed because the URL must be usable as a link for other users also. E.g. /fooApp/showProduct?id=123&db=foo

David Newton wrote:
perhaps using a filter or a custom request processor to put it back into the request if that's *really* necessary. I can't think of why it would be.

In any case, I'd look into a filter or a custom request processor.


Thanks, I'll check it out.

To clarify things little more, the problem is that a single .war on a single server (Tomcat 6.x) serves multiple stores. Stores have their own databases with products and content etc. So far the app has been password protected, thus providing the "entrypoint" for stores and the problem above has not existed.

In the future the app must be "open" and the problem is how to identify the store in the URL.

- Lari
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 1.x and permanent GET parameter for every Action.
 
Similar Threads
struts modules with JSPs in WEB-INF and public redirects
struts2: Mapping generic paths?
daily processing on Jboss
Web app deployment model depends on build.xml? (Lomboz)
html:form pointing to some outside url ?