title: How can I access a static variable from Java class in JSTL?
body: <p>I'm trying to use JSTL to hook into an Oracle database.  I have it working, but not in the way I'd like.  (The values for USER and PASSWORD have different values in the actual program but I didn't want to share them publicly)/</p>
  
  <pre><code>&lt;c:set var="DRIVER" value="oracle.jdbc.OracleDriver" scope="request" /&gt;
  &lt;c:set var="URL" value="dbc:oracle:thin:@localhost:1521:xe" scope="request" /&gt;
  &lt;c:set var="USER" value="REDACTED" scope="request" /&gt;
  &lt;c:set var="PASSWORD" value="REDACTED" scope="request" /&gt;
  
  
  &lt;sql:setDataSource var="dbDataSource" driver="${DRIVER}" url="${URL}"
      user="${USER}"  password="${PASSWORD }" /&gt;
  </code></pre>
  
  <p>So it's working, but I don't like using those string literals.  I have some static final int variable set in another Java class that hold the values so I can change them in one place if I need.  I can't figure out how to access these constants in my JSP file.</p>
  
  <p>I tried using a bean, then setting a JSTL variable:</p>
  
  <pre><code>&lt;%@ page import="myPackage.dbInfo" %&gt;
  &lt;jsp:useBean id="dbInfoBean" scope="request" class="myPackage.dbInfo"&gt;&lt;/jsp:useBean&gt;
  </code></pre>
  
  <p>And my class "dbInfo" contains the following definition for the DRIVER variable.</p>
  
  <pre><code>public static final String ALSODRIVER = "oracle.jdbc.OracleDriver";
  </code></pre>
  
  <p>Finally replacing the first of those  fields as such:</p>
  
  <pre><code>&lt;c:set var="DRIVER" value="${dbInfoBean.DRIVER}" scope="request" /&gt;
  </code></pre>
  
  <p>When I try to run the JSP, it doesn't work.  I get errors:</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page /authorize_registrations.jsp at line 13
  
  12: 
  13: &lt;c:set var="DRIVER" value="${dbInfoBean.ALSODRIVER}" scope="request" /&gt;
  14: &lt;c:set var="URL" value="dbc:oracle:thin:@localhost:1521:xe" scope="request" /&gt;
  15: &lt;c:set var="USER" value="REDACTED" scope="request" /&gt;
  16: &lt;c:set var="PASSWORD" value="REDACTED" scope="request" /&gt;
  </code></pre>
  
  <p>What am I doing wrong?  I'll use the string literals (which are working) if I have to, but I'm not crazy about it if I can avoid.</p>