• Post Reply Bookmark Topic Watch Topic
  • New Topic

Retrive a property from a .properties file to JSP custom tag  RSS feed

 
Np Knp
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a requirement where i need to read a set a value to a custom tag property by reading its value from a .properties file. When i read the value and display, it works fine, but when i assign it to custom tag property it gives me error.
Here is the code for application.properties file:
# For Sample Database
SampleDBName = genSQLServer
SampleDBUrl = jdbc:microsoft:sqlserver://SampleDB;DatabaseName=Sample
SampleDBUserName = prakash
SampleDBPassword = prakash123

JSP code:
<% Properties p = new Properties(); %>
<% p.load(new FileInputStream(new File("C:\\tomcat\\webapps\\sampleapplication
application.properties"))); %>

<SampleApplication:useSQLDataSource
name = "genSQLServer"
driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"
url = "<%=p.getProperty("SampleDBUrl ") %>"
username = �<%=p.getProperty("SampleDBUserName ") %>�
password = �<%=p.getProperty("SampleDBPassword ") %>�
remove = "true"/>

When i use the above code it throws an Exception "No suitable driver".
But when i use the following code it works fine:
<SampleApplication:useSQLDataSource
name = "genSQLServer"
driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"
url = "jdbc:microsoft:sqlserver://SampleDB;DatabaseName=Sample"
username = "prakash"
password = "prakash123"
remove = "true"/>

And more over when i print the "SampleDBUrl " property value in the JSP using <%=p.getProperty("SampleDBUrl ") %>, it print the correct value, only problem occurs is when i assign it in the custom tag property.

Please help me in resolving this issue.

Thanks and Regards.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got funny double quotes in your first example, after username and password. Is this a typo ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!