• Post Reply Bookmark Topic Watch Topic
  • New Topic

Substitute

 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I use struts. Can I write a code in such a way that when I use a keyword where ever in the files (java class or jsp) I want it to be substituted by a string which is predefined. If yes how can I do it. ex: I use "com.mysql.jdbc.Driver" in most of my class, can I have a substitution in such case, so that I dont have to write the whole thing again and again.

Thank you in advance.

 
Ninad Kulkarni
Ranch Hand
Posts: 802
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Mahi

Would you give more information about your goal? What you want to do really?
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ninad Kulkarni wrote:Hi, Mahi

Would you give more information about your goal? What you want to do really?


I have say 10 java class files. Now all of them contain the say "com.mysql.jdbc.Driver". I wish to know if I can declar a string say key= "com.mysql.jdbc.Driver". So then when ever I use key it should substitute "com.mysql.jdbc.Driver"

Thank you
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just use a variable?

Or you can inject a value via Spring, or create and use a property, or... there are many, many solutions.

If you're just trying to create a data source why not use either a server datasource or move the datasource configuration into Spring/Hibernate/etc.?
 
Mahesh Lohi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Why not just use a variable?

Or you can inject a value via Spring, or create and use a property, or... there are many, many solutions.

If you're just trying to create a data source why not use either a server datasource or move the datasource configuration into Spring/Hibernate/etc.?



Thank you for the reply
I use struts.

Please let me know how to set property in struts config.
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!