Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 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"))); %>

name = "genSQLServer"
driver = ""
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:
name = "genSQLServer"
driver = ""
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.
Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • 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 ?
a wee bit from the empire
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic