Action url

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Action url

Tamás Barta
Hi,

Is there any built-in method to assign URL pattern to an action (method)
out of the action code itself? I would like to use the same web app code
with different URLs (for different sites). My idea is to create a custom
URL mapper which reads url data from database or configuration files for
example. But I wonder if there is a built-in easier solution for it.

Thanks, Tamás
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Yasser Zamani-2


On 12/27/2017 9:28 PM, Tamás Barta wrote:
> I would like to use the same web app code
> with different URLs (for different sites).

Could you elaborate with an example, please?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Tamás Barta
For example there is a web application which has a LoginAction action. On
one site it is needed to access it via /login, on the other site /user/log.

It is just an example. The urls shouldn't be hard-coded in action
annotations as I don't want to clone the web application just to change
urls.

2017. dec. 27. 19:53 ezt írta ("Yasser Zamani" <[hidden email]>):

>
>
> On 12/27/2017 9:28 PM, Tamás Barta wrote:
> > I would like to use the same web app code
> > with different URLs (for different sites).
>
> Could you elaborate with an example, please?
>
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Dave Weis
I'm doing something similar and extended ActionSupport to put helpers to
access the user session and the site they went to in the first place.


On Dec 27, 2017 2:51 PM, "Tamás Barta" <[hidden email]> wrote:

> For example there is a web application which has a LoginAction action. On
> one site it is needed to access it via /login, on the other site /user/log.
>
> It is just an example. The urls shouldn't be hard-coded in action
> annotations as I don't want to clone the web application just to change
> urls.
>
> 2017. dec. 27. 19:53 ezt írta ("Yasser Zamani" <[hidden email]>):
>
> >
> >
> > On 12/27/2017 9:28 PM, Tamás Barta wrote:
> > > I would like to use the same web app code
> > > with different URLs (for different sites).
> >
> > Could you elaborate with an example, please?
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Yasser Zamani-2
In reply to this post by Tamás Barta


On 12/28/2017 12:21 AM, Tamás Barta wrote:
> For example there is a web application which has a LoginAction action. On
> one site it is needed to access it via /login, on the other site /user/log.

I'm just curious why you have to do such support. I think if I knew, I
could have better advice.

Thanks in advance!

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Yasser Zamani-2
In reply to this post by Tamás Barta


On 12/28/2017 12:21 AM, Tamás Barta wrote:
> For example there is a web application which has a LoginAction action. On
> one site it is needed to access it via /login, on the other site /user/log.
>
> It is just an example. The urls shouldn't be hard-coded in action
> annotations as I don't want to clone the web application just to change
> urls.

I think you can do these in several layers. At web server layer [1].
Simpler, at Servlet layer [2] or more harder, at Struts layer like [3].
It seems you just need rewriting url before Struts and if I were you, I
tried [2], a Servlet filter before Struts filter.

[1] https://en.wikipedia.org/wiki/Rewrite_engine#Web_frameworks
[2] http://tuckey.org/urlrewrite/
[3]
https://github.com/apache/struts/blob/master/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java#L188

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Tamás Barta
Your suggestions are ok for processing requests but are not to write urls
(how to determine correct url) in jsps or other presentation layer output.
To handle both sides a more sophisticated solution is needed.

2017. dec. 28. 10:19 ezt írta ("Yasser Zamani" <[hidden email]>):

>
>
> On 12/28/2017 12:21 AM, Tamás Barta wrote:
> > For example there is a web application which has a LoginAction action. On
> > one site it is needed to access it via /login, on the other site
> /user/log.
> >
> > It is just an example. The urls shouldn't be hard-coded in action
> > annotations as I don't want to clone the web application just to change
> > urls.
>
> I think you can do these in several layers. At web server layer [1].
> Simpler, at Servlet layer [2] or more harder, at Struts layer like [3].
> It seems you just need rewriting url before Struts and if I were you, I
> tried [2], a Servlet filter before Struts filter.
>
> [1] https://en.wikipedia.org/wiki/Rewrite_engine#Web_frameworks
> [2] http://tuckey.org/urlrewrite/
> [3]
> https://github.com/apache/struts/blob/master/plugins/
> rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java#L188
>
Reply | Threaded
Open this post in threaded view
|

Re: Action url

Yasser Zamani-2


On 12/28/2017 1:11 PM, Tamás Barta wrote:
> Your suggestions are ok for processing requests but are not to write urls
> (how to determine correct url) in jsps or other presentation layer output.
> To handle both sides a more sophisticated solution is needed.

As far as I can think, it seems you have to have a table (siteId,
action, url) for mapping. Then will have to override action mapper like
rest-plugin but is very simpler. Then will have to override Struts tags
whom generate url e.g. url and action tags and use your customized tags
in all jsps instead. Generally you will have both sides translator based
on that mapping table.

These are all what I'm able to think and I'm not sure if are good practices.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]