Thanx hemanth and vaibhav for your replies ..
Hemanth I have also tried your suggestion but it didn't work.
Vaibhav I m doing application - servlet communication therefore I cannot use the Oreilly examples u mentioned (I suppose). I m using these examples for extranet and its running successfully.
I made a list of all the methods related to path. But could'nt get the result. Below is the code and output I got..
Source ==>
public class trytest extends HttpServlet{
public void init(ServletConfig cfg){
try{
super.init(cfg);
cfg.getServletContext();
//System.out.println("cfg.getRealPath()" + cfg.getRealPath());
//System.out.println("cfg.getRealPath()" + cfg.getServletC());
}
catch(Exception e){
System.out.println(e);
}
}
public void doGet(HttpServletRequest req, HttpServletResponse res){
String str = "";
try{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
System.out.println("getAuthType() " + req.getAuthType() );
System.out.println("getCookies() " + req.getCookies() );
//System.out.println("getDateHeader(String) " + req.getDateHeader(String));
//System.out.println("getHeader(String) " + req.getHeader(String) );
System.out.println("getHeaderNames() " + req.getHeaderNames() );
//System.out.println("getIntHeader(String) " + req.getIntHeader(String) );
System.out.println("getMethod() " + req.getMethod() );
System.out.println("getPathInfo() " + req.getPathInfo() );
System.out.println("getPathTranslated() " + req.getPathTranslated() );
System.out.println("getQueryString() " + req.getQueryString() );
System.out.println("getRemoteUser() " + req.getRemoteUser() );
System.out.println("getRequestedSessionId() " + req.getRequestedSessionId() );
System.out.println("getRequestURI() " + req.getRequestURI() );
System.out.println("getServletPath() " + req.getServletPath() );
//System.out.println("cfg.getRealPath()" + ServletConfig.getRealPath(req.getServerName()));
str = getServletContext().getRealPath("/trytest");
String f = new File(str).getCanonicalPath();
str = System.getProperty("server_root");
System.out.println("Root : "+f);
}
catch(Exception ex){
System.out.println(ex);
}
}
}
Output ==>
getAuthType() null
getCookies() [Ljavax.servlet.http.Cookie;@63b895
getHeaderNames() org.apache.tomcat.util.MimeHeadersEnumerator@5e3974
getMethod() GET
getPathInfo() null
getPathTranslated() null
getQueryString() null
getRemoteUser() null
getRequestedSessionId() null
getRequestURI() /nitin/servlet/trytest
getServletPath() /servlet/trytest
Root : C:\jakarta-tomcat-3.2.1\webapps\nitin\trytest
Actual Path : C:\jakarta-tomcat-3.2.1\webapps\nitin\WEB-INF\classes
waiting for your replies guys,
nitin