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)/
<c:set var="DRIVER" value="oracle.jdbc.OracleDriver" scope="request" />
<c:set var="URL" value="dbc:oracle:thin:@localhost:1521:xe" scope="request" />
<c:set var="USER" value="REDACTED" scope="request" />
<c:set var="PASSWORD" value="REDACTED" scope="request" />
<sql:setDataSource var="dbDataSource" driver="${DRIVER}" url="${URL}"
user="${USER}" password="${PASSWORD }" />
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.
I tried using a bean, then setting a JSTL variable:
<%@ page import="myPackage.dbInfo" %>
<jsp:useBean id="dbInfoBean" scope="request" class="myPackage.dbInfo"></jsp:useBean>
And my class "dbInfo" contains the following definition for the DRIVER variable.
public static final String ALSODRIVER = "oracle.jdbc.OracleDriver";
Finally replacing the first of those fields as such:
<c:set var="DRIVER" value="${dbInfoBean.DRIVER}" scope="request" />
When I try to run the JSP, it doesn't work. I get errors:
org.apache.jasper.JasperException: An exception occurred processing JSP page /authorize_registrations.jsp at line 13
12:
13: <c:set var="DRIVER" value="${dbInfoBean.ALSODRIVER}" scope="request" />
14: <c:set var="URL" value="dbc:oracle:thin:@localhost:1521:xe" scope="request" />
15: <c:set var="USER" value="REDACTED" scope="request" />
16: <c:set var="PASSWORD" value="REDACTED" scope="request" />
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.