How can I use Weblogic (12 C) without the application context in the url?

I am working on a web project that requires a Weblogic server, and the only way to view the site after it is deployed (on my Macbook Pro) is to specify the application name as a prefix for the entire site. For instance.

http://localhost:7001/myapp-weblogic/ 

This breaks a ton of JavaScript style and code that access resources with root URLs (e.g. / images / example.png)

While I can programmatically add "/ my-app" to content in .jsp, I cannot do this in my .css files.

I tried setting the "Default WebApp root context:" in the Weblogic console> Environment> Servers> myserver> Protocols> HTTP. But that did not work.

It seems to be so simple. In IIS, I simply add a line to my local hosts file and add the host name to my IIS container, taking a total of about 42 seconds.

 127.0.0.1 myapp.local -> Let me view my site at http://myapp.local 

Thank you in advance for your understanding!


UPDATE !! Finally, I started to work. Some of them are very specific to my installation, but hopefully still useful to others.

To make it work, I needed to do 3 basic things and another related thing:

  • Set the default server application in Weblogic
    • On the local server, go to the console and log in
    • Go to: Weblogic> console> Environment> Servers> myserver> Protocols> HTTP
    • Set "Default WebApp Context Root:" to "/" + your application (for example, "/ myapp")
  • Set the context root of the project in MyEclipse
    • When opening a project in MyEclipse, right-click the project and select properties
    • Expand "MyEclipse" and select "Web" and set the Web Context-root to "/"
  • Set the context-root value in the weblogic.xml project file to "/"
    • This file should be located in the WEB-INF folder of your project.
    • Save the file and create the application
    • Redeploying the application - you may need to restart the server.

Setting my local path variable to "/"

So, one more thing that I had to do was set the path variable referenced by "/". When you request a path (request.getContextPath ();), it does not add the path with "/", and if you try to use something like <c:url context="${ _path }" if the _path variable does not start with "/", it will throw an exception.

This last bit was something I came across while working with other code.

+4
source share
2 answers

In application.xml specify the setting below

  <web> <web-uri>yourweb.war</web-uri> <context-root>/</context-root> </web> 

Now you can make a call without a context root as

  http://localhost:7001/ 
+2
source

I assume that you are using weblogic to deploy a Java application.

The structure should be a "war file".

Read more about the structure you can find here.

http://www.openscope.net/2010/01/25/war-deployment-file-structure/

The name of the context root (by default the name of the war) can also be redefined

https://forums.oracle.com/forums/thread.jspa?messageID=10366462

Hope this helps.

0
source

All Articles