Monday, March 9, 2015

ADF: URL simplification

In this blog I would like to describe how can we shorten url of our ADF pages. In ADF URL looks like 

http://127.0.0.1:7101/URLSimplification-ViewController-context-root/faces/MyPage.jspx?_afrLoop=6129381558176&_afrWindowMode=0&_adf.ctrl-state=onxhkg6zm_4

Our aim is to provide a simplified url like (http://sandemo.com) to end user and it should take him to our welcome page.

In above url _afrLoop=6129381558176&_afrWindowMode=0&_adf.ctrl-state=onxhkg6zm_4 gets added automatically so its not harming us. We can keep it as it is. Remaining url that needs to be simplified is http://127.0.0.1:7101/URLSimplification-ViewController-context-root/faces/MyPage.jspx

[URL redirection and simplification can be achieved using OHS but in this blog we will try it without OHS]

This url has following parts
1. http: This is protocol and we want it in our final url also so let it be like that
2. 127.0.0.1: This is m/c name. If we want to save sandemo.com we need to change our m/c name to sandemo.com. 
3. 7101: This is port. My weblogic server is listening at 7101 port. If I can change it to 80, I need not to pass it in URL. That way we can remove it from url.
4. URLSimplification-ViewController-context-root: This is a context root. We can deploy multiple web application on same weblogic server. Every application will have a unique context root. Using that weblogic knows which application to call. We can certainly reduce it but here we want to remove it from url. In other words we need to set it to /
5. faces/MyPage.jspx: This part is actually pointing to the page within application. We need to make sure if nothing is provided after context root, ADF should point to our welcome page. Which is faces/MyPage.jspx

As I don't have admin privileges on my box so I will not change my m/c name. So aim is if I type 127.0.0.1, on url, it should show me my welcome page.

We will perform following steps for URL simplification

1. Change port of web server to 80
2. Change context root to /
3. Set welcome page 


1. Change port of web server to 80: For this you need to open your console and select appropriate server on which you are going to deploy application. Change its listen port to 80. You can also change SSL Listen port if its https based application. Follow this navigation
   console > Environment > Servers > [Select appropriate server] > [Change port settings]


2. Change context root to /: You can change web-projects Java-EE Web Context root property for this but there is a catch. 


BUT BUT this does not work. The moment I try to save this setting I get error as




OK. Now lets try to play with jdeveloper and try to change this using a text editor directly. We can open UI project's jpr file and then search for property j2eeContextRoot. Now change its value to "/" as shown in below diagram.

If we open UI project's property we will see context-root is changed to "/". Use cancel to close project properties and run the page.

If we try to deploy it on admin server, we may found error as below

According to error there is another application that is running with / as a context root. We need to stop it. This application is nothing bur a welcome page application of weblogic and it gives information about weblogic server. We can stop it without any harm. Locate 'FMW Welcome Page Application' in weblogic deployments and stop it.


3. Set welcome page :
Welcome page setup is done in web.xml. Add following entry in web.xml
  <welcome-file-list>
    <welcome-file>/faces/MyPage.jspx</welcome-file>
  </welcome-file-list>


Now if you type only 127.0.0.1, system will redirect you to your welcome page. 

If your page is in a folder like com/san/pages, your initial url could be http://127.0.0.1:7101/URLSimplification-ViewController-context-root/faces/com/san/pages/MyPage.jspx. In such case you can generate an id for your jspx file by dropping it in adfc-config.xml. That way your url will change to http://127.0.0.1:7101/URLSimplification-ViewController-context-root/faces/MyPage. Now you can try to remove port and context-root from it.


4 comments:

Pandurang Parwatikar said...

Thanks Sanjeev. Really helpful and knowledgable

Unknown said...

what is m/c name

security technology  said...

It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks.

Muhammad Azwar said...

Nice Article, thanks for this information
Also check this out
Laptops, Mobiles, Games, Tv, Smartwatches etc Daily Tech News Updates.