jsp sayfasında;
ServletContext servletContext = pageContext.getServletContext();
String realPath = servletContext.getRealPath("/");
ile jsp sayfasının calisma dizinini alabiliyorum.
Burda kullanacagim javaclass ımda bu degiskene nasil erisebilirim
package com.belsoftlib;
import java.io.FileInputStream;
import java.util.Properties;
import javax.servlet.ServletContext;
public class IniOku {
String host;
String db;
String user;
String password;
public IniOku(){
ServletContext servletContext = pageContext.getServletContext();
String fileName = servletContext.getRealPath("/") + "belsoft.ini";
try{
Properties p = new Properties();
p.load(new FileInputStream(fileName));
this.host = p.getProperty("host");
this.db = p.getProperty("db");
this.user = p.getProperty("user");
this.password = p.getProperty("password");
}catch (Exception e) {
System.out.println(e);
}
}
}gibi bir class oluşturduğumda pageContext e erişemedigim için jsp sayfasının calisma dizinini bulamiyorum.
illaki jsp sayfasinda bu classi kullanmak istedigimde paremetre olarak mi gondermem gerekir. baska bir cozum yolu yokmudur.
yada paremetre dosyasi icin sizin oneriniz nedir
ilgilenenlere simdiden tesekkurler