tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <fzli...@omnytex.com>
Subject Re: switching
Date Sat, 03 Sep 2005 15:38:25 GMT
Hi,

sDriver, as well as all your other variables, are declared locally 
within the if block.  Once out of that block, they no longer exist.  So, 
when the code in conn_products.jsp executes, which would of course 
happen after that if block, those variables do not exist.

Add this right before the if block begins:

String sDriver;
String sUser;
String sPass;
String sDSN;

...and of course remove the String type declaration before each variable 
in the if block, and you should be good to go.

Frank

JhnVend@netscape.net wrote:
> Could someone point out what's wrong with this setup? 
> 
> I have a laptop, sometimes going offline and don't want to
> change strings each time I'm online or offline. (And don't want to run any
> db server on the laptop if I can avoid it.)
> 
> Error is here:
> 
> org.apache.jasper.JasperException: Unable to compile class for JSP
> 
> An error occurred at line: 1 in the jsp file: conn_products.jsp
> Generated servlet error:
> sDriver cannot be resolved
> 
> 
> 
> 
> In setup.jsp,
> 
> <%
> if(request.getServerName().equals("server.com")) {
>   String sDriver = "com.mysql.jdbc.Driver";
>   String sUser = "user";
>   String sPass = "password";
>   String sDSN = "jdbc:mysql://localhost:3306/products";
> } else if (request.getServerName().equals("localhost")) {
>   String sDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
>   String sUser = "";
>   String sPass = "";
>   String sDSN = "jdbc:odbc:products";
> }
> %>
> 
> In conn_products.jsp,
> 
> <%
>         String MM_products_DRIVER = sDriver ;
>         String MM_products_USERNAME = sUser ;
>         String MM_products_PASSWORD = sPass ;
>         String MM_products_STRING = sDSN ;
> %>
>   
> And in list.jsp,
>   
> <%include file="setup.jsp"%>
> <%include file="conn_products.jsp"%>
>   
> Jhn
> 
> __________________________________________________________________
> Switch to Netscape Internet Service.
> As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register
> 
> Netscape. Just the Net You Need.
> 
> New! Netscape Toolbar for Internet Explorer
> Search from anywhere on the Web and block those annoying pop-ups.
> Download now at http://channels.netscape.com/ns/search/install.jsp
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message