JavaMail - Mail session from JNDI(coded)

privatestatic Session getSession(){

Session session =null;

try{

Context ctx =new InitialContext();

Context envCtx = (Context) ctx.lookup("java:comp/env");

session = (Session) envCtx.lookup("mail/Session");

}catch (Exception e){

logger.error(e);

}

return session;

}

My question is basically that we have bound the mail/Session to the context and this code is picking it up from the server.xml file of tomcat.If i have to bind that in java code instead of server.xml(Server is not running),how to do that.Can anyone provide me with an example.

[1161 byte] By [JAVA.RULZa] at [2007-11-26 23:13:44]
# 1
This isn't easy.You need to implement a JNDI provider that supports the java: namespace.A simpler approach would be to encapsulate all the JNDI lookup ina class whose behavior or implementation you can change based onwhether or not you're running in a server.
bshannona at 2007-7-10 14:12:03 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...