pass parameters as the page name rather than as a query string (tomcat)

A

Austin

I am using apache struts with tomcat. I currently call URL's passing
parameters as a query string, straight forward stuff.

For example [host]/pageName.do?peram1=432&peram2=354

I now want to pass the parameters as part of the page name instead

For example [host]/pageName,432,354.do

Any ideas how this could be done?
 
B

Bryce (Work)

I am using apache struts with tomcat. I currently call URL's passing
parameters as a query string, straight forward stuff.

For example [host]/pageName.do?peram1=432&peram2=354

I now want to pass the parameters as part of the page name instead

For example [host]/pageName,432,354.do

Any ideas how this could be done?

Create a servlet, and create a mapping to it with a wildcard
(pageName*.do, or similar).

Now, when you handle your get or post, you can then parse the string
in the servlet...
 
V

VisionSet

Bryce (Work) said:
For example [host]/pageName,432,354.do

Any ideas how this could be done?

Create a servlet, and create a mapping to it with a wildcard
(pageName*.do, or similar).

Now, when you handle your get or post, you can then parse the string
in the servlet...

Do you know this to work?
The servlet spec (2.3) states:

.. A string beginning with a '/' character and ending with a '/*' postfix is
used
for path mapping.
.. A string beginning with a '*.' prefix is used as an extension mapping.
.. A string containing only the '/' character indicates the "default" servlet
of the
application. In this case the servlet path is the request URI minus the
context
path and the path info is null.
.. All other strings are used for exact matches only.

Certainly I have found the mappings to be fairly inflexible.
I have tried to map everything without an extension to one servlet, and
failed. What would it look like just * ? *.do matches all 'do' extensions,
so logically * would work for no extension, but for the spec above.

Your suggestion for 'page*.do' only complies with 'All other strings are
used for exact matches only'
 
A

Austin

thanks everyone. I tried pageName* as a path but this did not work.
Another thought is that i could store the perameters in the path for
example

[host]/432,354/pageName.jhtml

I am using apache connected with mod_jk2 maybe apache could do a
rewrite, i dont know
 
V

VisionSet

Austin said:
thanks everyone. I tried pageName* as a path but this did not work.
Another thought is that i could store the perameters in the path for
example

[host]/432,354/pageName.jhtml

I am using apache connected with mod_jk2 maybe apache could do a
rewrite, i dont know

I suggest

[host]/another/432,354/pageName.jhtml

In which case you'd need the mapping another/*
otherwise your servlet would get everything that wasn't exactly mapped
elsewhere.
Study the spec!

see HttpServletRequest for methods useful for examining various parts of the
url to extract your values.

Personally, I haven't found a need to do anything other than use the query
string.

You could still do pageName,423,354.do but you would either need the same
approach ie

[host]/another/pageName,423,354.do with the same mapping another/*

or use the default servlet (mapped to /) and redirect everything from there
a la controller.
 
A

Austin

I tried <action path="/SingleSignOnTest/*"
then requested the URL
[host]/SingleSignOnTest/anyname.do
and i got a 404 error
i then tried
[host]/SingleSignOnTest/*.do
and i got the page i was after

my intention if this worked is to request

[host]/SingleSignOnTest/456,423.do

with the numbers being the perameters.

I also tried '/*' '*.do'

thanks again


VisionSet said:
Austin said:
thanks everyone. I tried pageName* as a path but this did not work.
Another thought is that i could store the perameters in the path for
example

[host]/432,354/pageName.jhtml

I am using apache connected with mod_jk2 maybe apache could do a
rewrite, i dont know

I suggest

[host]/another/432,354/pageName.jhtml

In which case you'd need the mapping another/*
otherwise your servlet would get everything that wasn't exactly mapped
elsewhere.
Study the spec!

see HttpServletRequest for methods useful for examining various parts of the
url to extract your values.

Personally, I haven't found a need to do anything other than use the query
string.

You could still do pageName,423,354.do but you would either need the same
approach ie

[host]/another/pageName,423,354.do with the same mapping another/*

or use the default servlet (mapped to /) and redirect everything from there
a la controller.
 
A

Austin

I have been unable to get this working. I have tried all suggestions.
Do you have the URL where i can find the servlet spec for this please?

Regards
James
http://www.buyacar.co.uk


VisionSet said:
Austin said:
thanks everyone. I tried pageName* as a path but this did not work.
Another thought is that i could store the perameters in the path for
example

[host]/432,354/pageName.jhtml

I am using apache connected with mod_jk2 maybe apache could do a
rewrite, i dont know

I suggest

[host]/another/432,354/pageName.jhtml

In which case you'd need the mapping another/*
otherwise your servlet would get everything that wasn't exactly mapped
elsewhere.
Study the spec!

see HttpServletRequest for methods useful for examining various parts of the
url to extract your values.

Personally, I haven't found a need to do anything other than use the query
string.

You could still do pageName,423,354.do but you would either need the same
approach ie

[host]/another/pageName,423,354.do with the same mapping another/*

or use the default servlet (mapped to /) and redirect everything from there
a la controller.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top