X

Shay Shmeltzer's Oracle Development Tools Tips

Shorter URL for your ADF application

Shay Shmeltzer
Director of Product Management - Oracle

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.

Join the discussion

Comments ( 24 )
  • guest Wednesday, May 9, 2012

    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...


  • Shay Wednesday, May 9, 2012

    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".


  • Rory Wednesday, May 9, 2012

    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


  • Johannes Wednesday, May 9, 2012

    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


  • Shay Wednesday, May 9, 2012

    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


  • guest Wednesday, May 9, 2012

    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


  • Shay Wednesday, May 9, 2012

    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">


  • guest Thursday, May 10, 2012

    thanks a lot Mr.Shay now it working fine


  • reza Thursday, May 10, 2012

    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


  • guest Friday, May 11, 2012

    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.


  • guest Monday, August 27, 2012

    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


  • Shay Tuesday, August 28, 2012

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


  • puli Tuesday, August 28, 2012

    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.


  • Shay Wednesday, August 29, 2012
  • guest Thursday, October 25, 2012

    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


  • Shay Friday, October 26, 2012

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


  • guest Wednesday, January 23, 2013

    Hi Shay

    following what you described above my application goes on an infinite loop when i run in on weblogic server.

    Any ideas?

    Thanks


  • guest Wednesday, February 27, 2013

    how to do bookmark oracle adf


  • Shay Thursday, February 28, 2013

    guest - you can mark taskflow and pages in ADF to be bookmarable.

    See - https://blogs.oracle.com/shay/entry/passing_parameters_to_adf_appl


  • guest Monday, June 3, 2013

    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.


  • guest Monday, June 3, 2013

    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.


  • guest Friday, September 13, 2013

    hi

    How to short my adf web application url developed using ecplise


  • guest Friday, July 8, 2016

    Hi Shay

    I have faced the same requirement recently and i found that , if you want context of your application to set as "/" then you have to go to VIEWCONTROLLER ----->PROJECT PROPERTIES--> DEPLOYMENT-----> NOW EDIT THE WAR DEPLOYMENT PROFILE ----------> SET CONTEXT "/"

    if you will go to VIEWCONTROLLER---> PROJECT PROPERTIES---> JAVA EE APPLICATION---->> and change the JAVA EE WEB CONTEXT ROOT to "/" , JDeveloper will not allow you to enter the special characters in that field


  • Ubai Wednesday, April 3, 2019
    Thanks Shay, as usual simple and Straight.
    thank you very much for your way of presenting something.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.