I'm running Tomcat 8.5.11. I have a hopefully small problem.

I have a webapp directory: $CATALINA_HOME/webapps/myapp/. In that directory I 
have WEB-INF/web.xml with:

<env-entry>
  <env-entry-name>connURL</env-entry-name>
  <env-entry-value>jdbc:mysql://localhost/members?</env-entry-value>
  <env-entry-type>java.lang.String</env-entry-type>
</env-entry>

In this example, the env-entry is just part of an SQL connection string I want 
to snag.

In a browser, going to: <myIP>/myapp/index.jsp works fine with WEB-INF as shown 
above.

What I want to do is put all of this in a sub-directory: 
$CATALINA_HOME/webapps/myapp/subapp/ and access it on my browser as 
<myIP>/myapp/subapp/index.jsp. When I do that -- no changes to anything -- I 
get the error:

javax.servlet.ServletException: javax.naming.NameNotFoundException: Name 
[connURL] is not bound in this Context. Unable to find [connURL].

Here is the jsp code:

Context ctx = new javax.naming.InitialContext();
Context env = (Context) ctx.lookup("java:comp/env");
    
String _dbURL = (String) env.lookup("connURL"));

Clearly, the error has something to do with the extra subdirectory level. Also, 
when I do getServletContext().getRealPath("") in my jsp program it only returns 
"/srv/tomcat/webapps/myapp", not .../myapp/subapp

How do I fix this so env.lookup("") find my env-entry?

How do I get the path to the jsp file?

Thanks --Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to