Shorter URL for your ADF application

So you ran your application from JDeveloper and the URL you got was:

http://127.0.0.1:7101/Application154-ViewController-context-root/faces/untitled2.jsf

A common question is can I make this URL shorter and easy to remember?

Here is how you can get it to be http://127.0.0.1:7101/

The first step is to switch the Java EE Web contextroot setting of your application. Go to Project Properties of your view/controller project and under Java EE Application set the name to be something shorter like myapp or if you prefer even just "/". When you run your application on the embedded WLS in JDeveloper you might get an error saying:

Context path '' is already in use by the module: / application: FMW Welcome Page Application [Version=11.1.0.0.0]

This is because the built in WebLogic server comes with a welcome application that sits at this location. You can safely remove it using the application server navigator undeploy option.

Next step is to add an index.html file to your application and in that file just use an HTML Meta tag to do a redirect to the JSF file you want to access. So for example:

<meta http-equiv="refresh" content="0;url=/faces/untitled1.jsf">

That's it.

Now when people access your running server they'll get your JSF page without having to specify anything on the URL.

If you also want to remove the need for a port number (7101) then you can configure your WebLogic to listen on port 80, or alternatively install the Oracle Web Tier and have the web cache listen on port 80 and redirect to your 7101 port.

Note - don't forget to look at the comments to this entry - there are some additional tips there, like changing the faces part, pointing to an adfc-config entry instead of a page directly and using the welcome page option to do the redirect.

Here is a quick demo of how all the above is done.

Comments:

So basically, you have to redirect in order to get to the application. What about true URL Rewrite, pretty urls and so on? Because what you just proposed sucks so badly it hurts my eyes...

Posted by guest on May 09, 2012 at 10:48 AM PDT #

guest - I'm not saying that there aren't other solutions.
My aim here was to show a quick solution - and while doing this educate people about some configuration settings in JDev/WLS that they might not be aware of.
I would be interested to know why you think this "sucks so badly".

Posted by Shay on May 09, 2012 at 10:55 AM PDT #

Is it supported to rename the Faces servlet URL pattern? It would be nice to make it something short like /f/index.jspx. Also how about a way to make .jspx extension optional or the implied default

Posted by Rory on May 09, 2012 at 12:06 PM PDT #

Hi Shay,

you might wanna check this out:
http://www.tuckey.org/urlrewrite/

it is a URL reqrite filter for java web applications. Maybe you can get this or something similar to work together with ADF

Posted by Johannes on May 09, 2012 at 01:13 PM PDT #

Rory, you can change the servlet URL pattern - just edit the web.xml file with something like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/moo/*</url-pattern>
</servlet-mapping>

You can also eliminate the need for the jspx extension - just drag your jsf into the adfc-config.xml file and right click it there to run, and you'll see that your URL becomes something like:
http://127.0.0.1:7103/moo/untitled2

Posted by Shay on May 09, 2012 at 01:39 PM PDT #

Hi Mr.Shay,
thanks for your nice article but please i want ask you about my problem:
in my application I have two page after make redirect within index.html I can not navigate from first page to second page?
thanks
Morsal Zein

Posted by guest on May 09, 2012 at 04:11 PM PDT #

Morsal, if your navigation is defined in the adfc-config.xml file then make sure your meta redirect doesn't include the .jsf extension.
So it should be something like:
<meta http-equiv="refresh" content="0;url=/faces/untitled1">

Posted by Shay on May 09, 2012 at 04:26 PM PDT #

thanks a lot Mr.Shay now it working fine

Posted by guest on May 10, 2012 at 03:41 AM PDT #

I think if use the welcome-file tag in web.xml it is better than redirecting users.
sample:
<welcome-file-list>
<welcome-file>/faces/untitled1</welcome-file>
</welcome-file-list>

thanks

Posted by reza on May 10, 2012 at 04:03 AM PDT #

We had issues with this approach and sometimes IE doesn't redirect it properly. Also, back button can also behave incorrectly. (http://www.w3.org/QA/Tips/reback). We ended up reverting this change and instead added Redirect directive in OHS configuration.

Posted by guest on May 11, 2012 at 11:21 AM PDT #

Is there a way to convert to pretty urls with out re-creating an application ? I work on support, we have a Oracle Fusion Application Help portal instance. Wanted to check if there are some configuration changes ican try without changing the application.

thanks,
Puli

Posted by guest on August 27, 2012 at 03:17 PM PDT #

Puli, the changes I pointed out are all about the configuration of the application when it is deployed - no need to rewrite the application.

Posted by Shay on August 28, 2012 at 03:45 PM PDT #

thank you.
Am working on integrating a adf applciation with Akamai CDN, to see if i can cache the static content.
Akamai CDN caches based on urls.
Akamai also does not cache cookies.
Do you have any though or have you done any caching with webcache or CDN, cache static content on a adf application ?
appreciate your time.

Posted by puli on August 28, 2012 at 04:16 PM PDT #

You can use Webcache and CDN to cache static content in ADF applications.
https://blogs.oracle.com/ATEAM_WEBCENTER/entry/adf_faces_11g_ps5_new

http://andrejusb.blogspot.com/2010/06/oracle-webtier-11g-configuration-for.html

Posted by Shay on August 28, 2012 at 05:06 PM PDT #

Hi dear,

I'm using JDeveloper 11.1.1.6.0. But it's not solved.

Error:
Web Application context root is not valid URL path element. Characters: '#?*!/' are not allowed. Please specify a valid context root.

Thanks

Posted by guest on October 25, 2012 at 05:23 AM PDT #

guest - does it let you leave it blank? or possibly just change it in the deployment configuration on your weblogic server.

Posted by Shay on October 26, 2012 at 10:17 AM PDT #

Hi Shay
following what you described above my application goes on an infinite loop when i run in on weblogic server.
Any ideas?
Thanks

Posted by guest on January 23, 2013 at 06:57 AM PST #

how to do bookmark oracle adf

Posted by guest on February 27, 2013 at 04:05 AM PST #

guest - you can mark taskflow and pages in ADF to be bookmarable.
See - https://blogs.oracle.com/shay/entry/passing_parameters_to_adf_appl

Posted by Shay on February 28, 2013 at 03:40 PM PST #

Hi Shay,
I was developing 2 ADF applications. But for one of the application in the URL it was not showing .jspx it simply shows faces/homepage where as other application i am able to see faces/homepage.jspx. So if i need to get .jspx to URL then what should i need to do.

Posted by guest on June 03, 2013 at 04:36 AM PDT #

guest - I'm not sure I understand your question - better ask it with more details on the ADF forum on OTN.
In general if you are using the ADF controller layer you shouldn't be specifying jspx in the URL that invokes your application.

Posted by guest on June 03, 2013 at 10:01 AM PDT #

hi
How to short my adf web application url developed using ecplise

Posted by guest on September 13, 2013 at 03:49 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today