How do I get the real path!!!

I am trying to get the real path:
http://xxxxx/listusers.do?section=xxx
But when I am using request. getRequestURI() I get
listuser.jsp which is the value that listusers.do returns.
How do I get the real path?????

hehe
You can't get the real path from a virtual
path..that's why you have virtual paths.

Similar Messages

  • How to get the real path of the xml file

    I have a java application
    following is the package structure
    com>>gts>>xml
    having file---------> MyXML.xml
    com>>gts>>java
    having java program to read the file
    Problem is if I use File file = new File("..\\xml\\MyXML.xml");
    java.io.FileNotFoundException: E:\LEARNING_WORK_SPACE\JavaXml\..\xml\MyXml.xml (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    How do I get the real path of the xml file.
    Edited by: shashiwagh on Jan 29, 2010 11:46 AM

    Hi,
    if your XML file is inside a package you can easily get it from the classloader.
    Note that your application maybe packaged inside a jar so it is not safe to use java.io.File for this purpose.
    You have an xml file in :
    com/gts/xml/MyXML.xml
    in a class of the same module (that will packaged in the same jar) for example com.gts.java.XmlLoader :
    // To get the stream :
    InputStream is = this.getClass().getResourceAsStream("/com/gts/xml/MyXML.xml");
    // Or the URL :
    URL xml = this.getClass().getResource("/com/gts/xml/MyXML.xml");Hope it helps.

  • M8020 how do I get the real OEM VISTA premium cds ?

    M8020:
    How do I get the real OEM VISTA premium cds ? processor fan enclosure (plastic) is broken, HP does not have part, Constant BSOD's, VIsta reports inaccurate errors, excessive loud fan noise. Looks like HP did NOT tested this platform well !

    fixmaipc,
       The recovery discs are the only method HP supplies with which to install your operating system.  That being said, there are also several repair options available on the recovery discs, including hardware diagnostics and startup repair.  When you boot to the first recovery disc, choose advanced options, and it will provide you with the additional tools available for diangosing and repairing your PC.
    Regards,
    Although I am an HP Employee, the advice given here is my own, and not necessarily that of HP's.
    Please post rather than send me a Message. It's good for the community and I might not be able to get back quickly.

  • How to get the real path of the application in a JavaBean?

    Hi everyone,
    I know this has been asked several times before, but I I am not really satisfied with the answers... :-)
    I am writing a webapp which uses XML files for storing information, the "business" logic is in JavaBeans. So far I just used hardcoded paths, now I will have to put the thing on a server and need a better solution.
    I understand I can use getServletContext().getRealpath() but that doesn't work in a Bean.
    One solution would be to fill a (hidden) field calling that and passing the field to the Bean, but I don't really like that solution.
    I am using Java Studio Creator 2 (Update 1), isn't there a way to access the ApplicationBean instance in my JavaBeans? As I understand it, I could get the path from there as well.
    Thanks!

    When you create the bean that contains the business logic you will have to pass in the real path either as a constructor parameter or by setting a property of the bean.

  • How to get the Real Path of a file which is accessed  by URL?

    iam using tomcat6.0.
    I have a file xyz.xml at the top of the webapplication HFUSE which i can able to access by URL
    http://localhost:8080/HFUSE/xyz.xml
    My problem is how to get the realpath of the file "xyz.xml" for reading and writing purposes.
    I tried various things but i could not able to successfully solved the problem?
    1) File f = new File("/xyz.xml");
    print(f.getAbsolutePath()) ============== it is not fetching the file @ http://localhost:8080/HFUSE/xyz.xml rather it is creating a file
    at the root of the drive where eclipse is running.
    2) File f = new File("xyz.xml");============> this is also not working , it is creating the file xyz.xml in the eclipse directory ..................
    Can anyone please guide on this problem?

    RevertInIslam wrote:
    If you want your context root(i.e HFUSE)
    use this:
    request.getContextPath() //where request is HttpServletRequest object to get the needful path.
    e.g:
    File f = new File(request.getContextPath()+"/xyz.xml");//it will create the file inside HFUSE.
    Hope this helps.
    Regards
    BWrong. The File constructor expects an absolute filesystem path. The HttpServletRequest#getContextPath() doesn't return the absolute filesystem path, it only returns the relative path from the current context root. Use ServletContext#getRealPath() instead, it returns the absolute filesystem path for the given relative path from the current context root.
    File file = new File(servletContext.getRealPath("/"), "xyz.xml");

  • How do I get the full path and filename of the current document?

    I'm writing a format plug-in. How do I obtain the full path and filename of the current image (document) from within my plug-in? Any help would be greatly appreciated!

    I actually just figured this out. For anyone else who would like to know, check out the propetizer sample code in the photoshop sdk. It makes a "filter" plug-in that just spits out all the properties of the document you could ever want to know about. The function I used to get the full path and filename of the current document is PIGetDocumentName(). I hope this helps someone eventually...

  • How can I get the real column of an alias in a view using system catalogs?

    Given a view with columns that use aliases, I would like to get the real column name for the view column with the alias.
    For example,
    CREATE VIEW myView AS
    SELECT name as col_1, price as col_2, price + 1000 as col_3
    FROM myTable
    I want to get that 'col_1' is actually the 'name' column and 'col_2' is the 'price' column by querying the system catalogs of SQL Server. It would be great to know whether I can resolve what 'col_3' is in the
    example as well (i.e., when an alias is an expression, not just a column). 
    Thanks in advance.

    Or you can use the System function
    sys.dm_exec_describe_first_result_set, example
    CREATE TABLE myTable
    (name varchar(30), price money);
    GO
    CREATE VIEW myView AS
    SELECT name as col_1, price as col_2, price + 1000 as col_3
    FROM myTable;
    GO
    SELECT name, source_table, source_column
    FROM sys.dm_exec_describe_first_result_set(N'SELECT * FROM myView', NULL, 1) AS FRS
    =>
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How can i get the local path to my cached app in jws

    Hi,
    sorry, i think it is a stupid question of me. but i'm a newbie in java and jws...
    So my question is...
    is it possible to get the absolute path to my downloaded an d cached jarfile? (e.g. c:\program files\java web start\.javaws\cache\http\Dmy.server.com\P80\RMmyapp.jar)
    thanks a lot for any help.

    I just answered this elsewhere, but here it is again.
    This code seems to work. I found it last year in one of the forums.
    I use it to find resources in Jars or to find images when I am in an IDE
    The "SetIcon.class" below should be changed to the class you are running from.
    Note: If you are running a class in a package, this returns the root of your application instead of the "folder" containing your package. This would mean that the "images" folder I refer to below is under the root folder, not the package folder.
    javax.swing.ImageIcon img;
    URL imgPath1;
    String imgPath2;
    imgPath1 = SetIcon.class.getProtectionDomain().getCodeSource().getLocation();
    imgPath2 = imgPath1.toString();
    imgPath2 = imgPath2.substring(6); // strip off the "file:"
    imgPath2 = imgPath2 + "images/sample.gif";
    Hope this helps,
    Hale

  • Problem for getting the real path using one servlet and one jsp page

    I have one tomcat machine and several virtual domains. Eahc virtual domain has one realpath in the disc.
    I am using one servlet and one jsp page for using this servlet.
    my purpose is to load, using the servlet , the real path for the domains (eahc domain has its path).
    for this i make this:
    the servlet code is this:
    package utils.ticker;
    import java.io.*;
    import java.io.File;
    import java.io.IOException;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletContext;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class Edicion extends HttpServlet{
    public Edicion() {
    public String cc(){
    ServletContext myContext= getServletContext();
    String abspath = myContext.getRealPath("/");
    //here i want to return the real path
    return abspath;
    public static void main(String args[]){
    and the jsp page is:
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%
    tick.cc();
    %>
    </body></head></html>
    But this produces one error, NullPointerException and dont shows me the real path.
    Can anyone help me?
    thanks

    i have put this into one sevlet:
    package utils.ticker;
    import javax.servlet.ServletContext;
    public class Edicion{
    private ServletContext myContext;
    public Edicion(ServletContext myContext) {
    this.myContext = myContext;
    public String getCC(){
    return myContext.getRealPath("/");
    and in the jsp page this:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
    <%@ page import="utils.ticker.*" %>
    <jsp:useBean id="tick" class="utils.ticker.Edicion" scope="session"/>
    <html><head><body>
    <%=tick.getCC()%>
    </body></head></html>
    but appear this error in the tomcat.
    Can you, please, help me. i am trying to solve this during one week and i am desesperate.
    Thanks.
    ERROR:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    javax.servlet.ServletException: class utils.ticker.Edicion : java.lang.InstantiationException: utils.ticker.Edicion
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
         at org.apache.jsp.pruebas_jsp._jspService(pruebas_jsp.java:72)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
         at java.lang.Thread.run(Thread.java:536)
    Apache Tomcat/4.1.18

  • How can I find the real path to servlet class

    Hi,
    I am facing an issue. Am in the process of creating a filter which would send a Last-modified along with the header. For this I will be checking the is-modified-since
    header and lastModified date of the file.
    The problem I am facing is that after taking the file part from the request and checking
    the lastmodified date, it gives error. This is because i use,
    String real_path = getServletContext().getRealPath(request.getServletPath());
    and it would return the path to servlet-name and not to servlet-class, since servlet-name
    is not physically present. It would return an error value.
    Is there any way which I could find the real path to my servlet class file ?

    Remember you should not take the last mnodified date
    of the class file or the jar file that contain the
    class as the value for the getLastModified method
    becouse the last modified date that should be used in
    the caching is the last modified date of the dynamic
    content that the servlet is about to prodice.
    The same class file will produce different content
    for different requests if not why do you use
    servlets you can directly use the static contentThanks for a valuable remark.
    Hence our getLastModified() often returns System.currentTimeMillis() result.

  • I had io6 Beta. How do I get the real ios6 now?

    I'm not sure if it's possible but since I've had the Beta for ios6 for a month now is possible to download today's update and fix the bugs?
    Thansk for all help in advance.

    claude19 wrote:
    I'm not sure if it's possible but since I've had the Beta for ios6 for a month now is possible to download today's update and fix the bugs?
    Thansk for all help in advance.
    As a registered Apple Developer that you are, you should know how to do this by looking into the documentation Apple provided to you .

  • How can I get the file path which located on webapps/MY_APPS ?

    Hi,
    I use tomcat as our servlet container.OS is win2k srv
    my project was put on x:\tomcat\webapps\MY_APPS
    and I could use getServletContext().getRealPath("/") within a servlet to get x:\tomcat\webapps\ROOT\MY_APPS,
      public void doPost(HttpServletRequest request,
                         HttpServletResponse response)
        throws ServletException, IOException
           String myAppsPath = getServletContext().getRealPath("/");
      }but I could not utilize this method within a normal help class
    any suggestion will be welcome.
    thanks in advance.

    try this:
    package com.sample;
    import java.io.File;
    public class SampleClass
      public SampleClass()
       * @param args
      public static void main(String[] args)
        SampleClass sampleClass = new SampleClass();
        File f = new File("SampleClass.class");
        System.out.println(f.getAbsolutePath());
    }

  • How to get the absolute path of a DTD referenced in an XML?

    Hello!
    My OS is Windows.
    I use "org.apache.xerces.parsers.SAXParser" which implements LexicalHandler to parse XML files. When method "startDTD" starts and "systemId" is got, how can I get the absolute path? Is there any simple way?
    Regards!

    Hi,
    http://forum.java.sun.com/thread.jsp?forum=34&thread=36
    612The methods in the above topic seem to be available when use a DOM parser..

  • How to get the ablolute path of the web application in WebSphere?

    How to get the ablolute path of the web application in WebSphere?
    For example:
    I have installed IBM WebSphere on D:\WebSphere\Appserver, and I created a new appliction named "myapp" on D:\myapp,. How can I get the absolute path of application "myapp"? In other words,how can I get the absolute path of the application's
    root directory?

    In the WebSphere(default), what directory is the Java Bean's root directory ?

  • How to get the project path ?

    In my servlet, how do I get the project path ?
    I have the following dir structure :
    Web_App
      + build
        lib
      + nbproject
      + src
        test
      + web ( index.jsp , my.jsp , my.html )
        + Dir_Docs ( my file : ABC.txt ) My Servlet is :
    public class My_Servlet extends HttpServlet
      public void init(ServletConfig config) throws ServletException
        super.init(config);
      public void destroy() { }
      protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
        response.setContentType("text/html");
        PrintWriter out=response.getWriter();
        out.println(System.getProperty("user.dir"));   
    }What I got was : C:/apache-tomcat-6.0.14/bin/
    How to get the project path ? Which is : C:/Web_App/ ?

    Yes, config.getServletContext().getRealPath("index.jsp"); got the job done !
    Thanks.

Maybe you are looking for