• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP property file  RSS feed

 
nagaraj kh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
i am new to jsp. can anyone tell me how to create a property file for a jsp page and retrieve data from that.

the scenario is i have path in my JSP page:in that am referring to a file using following URL.
String filename = "C:\\Documents and Settings\\hittal n\\Desktop\\Orchestrator\active.xls
i have to put this URL in property file and i have to read to from property file...the path should be absolute path in JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"nagaraj kh",please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not something that should be done in the JSP, but in a servlet controller or other Java class.

In fact, if the value is unlikely to change over the span of the application, you could read the properties file in a context listener and place the value as a scoped variable in application scope. It would then always be available when needed.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please avoid the over-use of bold in your posts. It just makes them hard to read
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Load this url, which is dynamic data when your application starts up. Use a servlet context listener. Use a context param like Le Bear suggests. JSPs are meant to display the page alone and should ideally not contain any other logic.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!