title: How can I use Weblogic (12 C) without the application context in the URL?
body: <p>I am working on a web project that requires Weblogic server and the only way I can view the site after deploying (on my Macbook Pro) is by specifying the application name as a prefix to the entire site. E.g.</p>
  
  <pre><code>http://localhost:7001/myapp-weblogic/
  </code></pre>
  
  <p>This breaks a ton of styling and JavaScript code that access resources with root URLs (e.g. /images/example.png)</p>
  
  <p>While I can programmatically add "/my-app" to content in a .jsp, I can't do that in my .css files. </p>
  
  <p>I tried setting the "Default WebApp Context Root:" in Weblogic > console > Environment > Servers > <em>myserver</em> > Protocols > HTTP - But that did not work.</p>
  
  <p>This seems like it should be such a simple thing. In IIS I would simply add a line to my local hosts file and add the host name to my IIS container - taking me a grand total of about 42 seconds.</p>
  
  <pre><code>127.0.0.1   myapp.local  -&gt; Let's me view my site at http://myapp.local
  </code></pre>
  
  <p>Thank you in advance for any insight!</p>
  
  <hr>
  
  <p>UPDATE!!
  I finally got things working. Some of this is very specific to my setup, but hopefully still helpful to others.</p>
  
  <p>To get it working I needed to do 3 main things and one other related thing:</p>
  
  <ol>
  <li>Set the default application for the server in Weblogic
  <ol>
  <li>On your local server, go to the console and log in</li>
  <li>Go to: Weblogic > console > Environment > Servers > <em>myserver</em> > Protocols > HTTP</li>
  <li>Set the "Default WebApp Context Root:" to "/" + your application (e.g. "/myapp")</li>
  </ol></li>
  <li>Set the context-root of the project in MyEclipse
  <ol>
  <li>With your project open in MyEclipse, right-click on the project and select properties</li>
  <li>Expand "MyEclipse" and choose "Web" and set the Web Context-root to "/"</li>
  </ol></li>
  <li>Set the value of context-root in the project weblogic.xml file to "/"
  <ol>
  <li>This file should be located in the WEB-INF folder of your project</li>
  <li>Save the file and build the app</li>
  <li>Redeploy your app - you may need to restart your server too</li>
  </ol></li>
  </ol>
  
  <h3>Setting my local path variable to "/"</h3>
  
  <p>So another thing I had to do was set a path variable i was referencing to "/". When you request the path (request.getContextPath(); ) it does not prepend the path with a "/" and if you try to use something like <code>&lt;c:url context="${ _path }"</code> if the the _path variable does not begin with a "/" it will throw an exception. </p>
  
  <p>That last bit was something I encountered from working with someone else's code.</p>