0

In opencms i want to access single container page with multiple urls

for Ex: consider a xyz container page i want access the container page with multiple urls reffered as below

    1>localhost:8080/xyz/abc

    2>localhost:8080/xyz/abc?id=xxxabc.

Suggest me how to achieve this. i am trying to achieve this using http://tuckey.org/urlrewrite/

suggest me other options also

Gora
  • 417
  • 2
  • 5
  • 14
  • Can you clarify your question? What does the second url show if not the container page? If the first url shows it fine, I don't see why appending any url parameter should not work or why you would need to use a urlrewrite. – Mathias Conradt Jan 21 '16 at 19:36
  • both urls will show same container page, in this aspect resource i.e. container page is present at path localhost:8080/xyz. But urls will be as shown above. i need to call resource internally with out changing url in browser how can i achieve this – Gora Jan 22 '16 at 05:04

2 Answers2

1

I am using http://tuckey.org/urlrewrite/ filter for removing opencms/opencms in url.

Regular expressions can be used for assigning multiple urls to single container page. Tuckey filter provides urlrewrite.xml, specify the rule tag here

<rule>
        <from>/products/([0-9]+)</from>
        <to>/products/index.jsp?product_id=$1</to>
</rule>
Gora
  • 417
  • 2
  • 5
  • 14
0

Above mentioned tuckey urlrewrite should be fine; you would need to configure it as a FORWARD.

If you want to do it within your OpenCms JSP template directly, you can do a forward directly in JSP like this:

<% if(request.getParameter("id")==null) request.getRequestDispatcher("/xyz/abc?id=xxxabc").forward(request, response);%>

But such code in JSP is usually not best-practice. Using tuckey urlrewrite is probably a cleaner approach.

Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • here my url in browser will be like localhost:8080/xyz/abc, but resource is at localhost:8080/xyz so there is the problem. we can't use forward in the jsp – Gora Jan 22 '16 at 08:56
  • I don't see why you cannot use a forward there? Does localhost:8080/xyz/abc not get served through a jsp template? Is it a Java-coded servlet? What kind of resource is it? – Mathias Conradt Jan 22 '16 at 08:59
  • Resource is opencms container page, this is present at localhost:8080/xyz. – Gora Jan 22 '16 at 09:30
  • 1
    In that case, you can create a new jsp file within OpenCms at localhost:8080/xyz/abc and put above forwarding into that jsp file, pointing to localhost:8080/xyz. (Note that the urls you mention here differ from your original post; in the original post, you have just the ?id-parameter as a difference, while here you have /xyz/abc which should lead to /xyz.). That case is actually simpler. I don't see why you couldn't simply create a new resource at /xyz/abc with a forward in it. – Mathias Conradt Jan 22 '16 at 09:33