• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've got funny double quotes in your first example, after username and password. Is this a typo ?
reply
    Bookmark Topic Watch Topic
  • New Topic