Creating a folder in web application directory?

Hi
I have a web application which contains some jsps and servlets and i am running it on Apache Tomcat 4.1. The name of my application is MyApp which contains all the servlets and jsps.
In order to deploy the application i have placed the MyApp folder in the 'webapps' folder of Tomcat. Now in one of my servlets i.e. 'DirectoryCreator', i am trying to create a folder i.e. 'Directory' in the MyApp folder. The problem is that i dont want to give an absolute path to the File class constructor. The class files of my servlets are in classes folder i.e. MyApp \ Web-INF \ classes.
I have tried:
File f = new File("/Directory");
f.mkdir();
but this creates the Directory folder in my C drive.
Please tell me how i can avoid giving the absolute path.
Thanks.

if the code to create the directory is a servlet, you can use
String path=getServletContext().getRealPath("/");
//getRealPath("/") will return the actual path on your machine of the base directory
//of the webapp. getRealPath("/SomeDirectory/SomeFile") will return the real
//path of SomeFile
File f=new File(path + "/Directory");
if(!f.exists())
    f.mkdir();if the code is in a .jsp file simple replace getServletContext(). with application.

Similar Messages

  • Where should one register a web application directory

    Hi:
    I have created a server domain and server instance for weblogic 8.1. Could someone
    please tell me where I should register the web application directory so that my
    jsp files could be served from this directory or a sub-directory of this web application
    directory?
    Thanks in advance.
    Rino

    Yes, it did work!
    Thanks a lot.
    Rino
    "Deepak Vohra" <[email protected]> wrote:
    >
    Rino,
    Is directory structure of the WebApplication the following?
    user_projects/mydomain/applications/myWebApp/jsp/HelloWorld.jsp
    myWebApp/WEB-INF/web.xml
    myWebApp/WEB-INF/weblogic.xml
    thanks,
    Deepak
    "Rino" <[email protected]> wrote:
    I did put the web application directory "myWebApp" under the "applications"
    folder
    but it still gives me error 404-Not Found.
    The content my my weblogic.xml file is as follows:
    <!DOCTYPE weblogic-web-app PUBLIC "-//BEA
    Systems, Inc.//DTD Web Application 8.1//EN"
    "http://www.bea.com/servers/wls700/dtd/weblogic700-web-jar.dtd">
    <weblogic-web-app>
    <context-root>myWebApp</context-root>
    </weblogic-web-app>
    Can someone explain me how the applications folder serves the jsp pages?
    And
    also what I may be doing wrong
    Thanks.
    Rino
    "Deepak Vohra" <[email protected]> wrote:
    I created a web application directory "myWebApp" under my weblogichome directory.
    The web application directory "myWebApp" should be under the 'applications'
    directory.
    thanks,
    Deepak
    "Rino" <[email protected]> wrote:
    Thanks for your response. However, I still could not get it to work.
    My weblogic home is "C:\bea\weblogic81"
    I created a web application directory "myWebApp" under my weblogic
    home
    directory.
    I also created a WEB-INF folder under "myWebApp" directory.
    After this I created "weblogic.xml" file under the WEB-INF folder.
    The content of my weblogic.xml file is as follows:
    <!DOCTYPE weblogic-web-app PUBLIC "-//BEA
    Systems, Inc.//DTD Web Application 7.0//EN"
    "http://www.bea.com/servers/wls700/dtd/weblogic700-web-jar.dtd">
    <weblogic-web-app>
    <context-root>myWebApp</context-root>
    </weblogic-web-app>
    Under my web application folder i.e. "myWebApp" I have a sub-directory
    named jsp.
    In this sub-directory I placed my helloworld.jsp file.
    Now when I try to run my jsp file from the browser as follows.
    http://localhost:port/jsp/helloworld.jsp
    I get an error message "Error 404-Not Found
    Could someone let me know what I am doing wrong here?
    Thanks in advance.
    Rino
    "Deepak Vohra" <[email protected]> wrote:
    The applications directory has a default Web Applications directory,
    DefaultWebApp.
    To specify a Web Applications dir other than the DefaultWebApp dir,specify
    the
    web app dir in
    the context-root element of weblogic.xml deployment descriptor.
    thanks,
    Deepak
    "Rino" <[email protected]> wrote:
    Hi:
    I have created a server domain and server instance for weblogic
    8.1.
    Could someone
    please tell me where I should register the web application directory
    so that my
    jsp files could be served from this directory or a sub-directoryof
    this
    web application
    directory?
    Thanks in advance.
    Rino

  • How do I create a folder in the root directory

    Hi
    How do I create a folder in the root directory?
    Once I do that I need to create a note book file in that folder
    Any help would be much appreciated
    Thanks
    Brian

    Hi Brian,
    Open Macintosh HD in the Finder, then SHIFT+CMD+n
    Root Directory is the top level of the drive.

  • How to create a file under web application root from java program

    how to create a file under web application root from java program like an action class?

    like an action class?Huh? What exactly is your requirement?
    Creating a file is usually done with java.io API. Read the java.io tutorials how to play with files.

  • Nested web applications directory.

    I recently design the jsp development structure in my company.
    It is basically contain two webapps which is productionLine webapp and developmentLine webapp.
    In my developmentLine webapp contain several programmers. Each of them has their own user directory in developmentLine webapp but i face a trouble which is each subdirectory cannot run their servlet in WEB-INF.
    In http://localhost/developmentLine/servlet/servletname is running fine but once i move the webapp into user directory then it cause the problem like http://localhost/development/John/servlet/servletname. It is not working. Any idea about it?
    design jsp development structure based.
    root
    -> productionLine
    \t -> HR
    \t -> Admin
    -> developmentLine
    -> John
    -> HR
    -> webster
    -> Admin
    Is the tomcat support nested webapplication? else i think i need put entire servlet in the common library to shared among each web applications.
    Edited by: webster on Nov 15, 2008 12:30 PM

    Because my company didn't install the any Java Tools before. I need to install entire java development Tools and assigned each particular directories in Tomcat web server for each developer. what's mean of "hacked"?
    I intent to put assigned each developer a userId directory in developmentLine directory. what i trying to do is allow each userId subdirectory in web application directory (i.e. ROOT, webdav, balancer and etc) to have their own servlet classes in WEB-INF directory.
    cause my company required put all the source code into a single server. Their think it is much more easier to maintain.
    so I am trying to install two tomcat in a server. I had change my http port, shutdown port and AJP port to 80, 89 and 85. When i try install a new Tomcat with same version into server, it pop up an error msg.
    Failed to install Tomcat5 service.
    Check your settings and permissions
    Ignore and continue anyway (not recommended)
    I choose ignore it, and continue install. Afterward my web application in port 80 change to 8080. I think it is replace the old tomcat server instead of running both tomcat together.
    Any idea?
    p/s: previous tomcat installation path is C:\Program Files\Apache Software Foundation\Tomcat 5.5 and another tomcat server installation path is C:\Program Files\Apache Software Foundation\Tomcat 5.52.
    Edited by: webster on Nov 17, 2008 10:39 AM

  • Database connection error | created a new datasource | web application

    Hi,
    I am trying to deploy a J2EE web application on SAP Netweaver 7.0. I have to connect to a Oracle database schema (Not the default schema used by SAP). I am using Java and JDBC to make connections to the database.
    In order to accomplish this, I created a new data source in Visual Admin. Referenced this in the web.xml and deployed the application. The application is deployed successfully, without any errors or warnings.
    However, when ever the Java program connects and executes a prepared statement, I get this error in the database logs
    bc.direct.DirectPreparedStatement#Java#com.sap.sql_0003#com.sap.sql.log.OpenSQLResourceBundle#SQL error occurred on connection xxxx111:xxx:xxx: code=942, state="42000", message="ORA-00942: table or view does not exist
    SQL statement is "SELECT "XMLVALUE" FROM "BC_DDDBTABLERT" WHERE "NAME" = ?".#5#942#42000#ORA-00942: table or view does not exist
    #solad011:pidb:PIUSER#SELECT "XMLVALUE" FROM "BC_DDDBTABLERT" WHERE "NAME" = ?#
    In java code, there are no references to this table "BC_DDDBTABLERT". I am trying to execute a SQL select for entirely different table. Why I am I getting this error?

    Hi,
    System copy NW 70 - Error in "export from java database" phase
    I am doing system copy of BI7.0 (Abap+Java) stack, I am getting error in
    "export from java database" phase as mentioned below.
    When I tried to run the query mentioned in SAP Note 1120872: ,
    SQL> DELETE FROM BC_DDDBTABLERT WHERE NAME = 'CAF_GP_R3USRMPGCFG';
    DELETE FROM BC_DDDBTABLERT WHERE NAME = 'CAF_GP_R3USRMPGCFG'
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> DELETE FROM BC_DDDBTABLERT WHERE NAME = 'CAF_GP_IF_CONTEXT';
    DELETE FROM BC_DDDBTABLERT WHERE NAME = 'CAF_GP_IF_CONTEXT'
    ERROR at line 1:
    ORA-00942: table or view does not exist
    I tried your Native_SQL also, but same error.
    Kindly help me on this.
    Regards,
    Sampath.
    SAP INST error log:
    ERROR 2010-10-15 10:32:35
    CJS-30049 Execution of JLoad tool '/usr/java/j2sdk1.4.2_12/bin/java
    -classpath /usr/sap/BD1/SYS/global/sltools/sharedlib/launcher. jar
    -showversion -Xmx512m com.sap.engine.offline.OfflineToolStart
    com.sap.inst.jload.Jload
    /usr/sap/BD1/SYS/global/security/lib/tools/iaik_jce .jar:/usr/sap/BD1/SYS/global/security/lib/tools/ia ik_jsse.jar:/usr/sap/BD1/SYS/global/security/lib/tools/ia ik_smime.jar:/usr/sap/BD1/SYS/global/security/lib/tools/ia ik_ssl.jar:/usr/sap/BD1/SYS/global/security/lib/tools/w3 c_http.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/jlo ad.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/ant lr.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/exc eption.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/jdd i.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/log ging.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/off lineconfiguration.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/ope nsqlsta.jar:/usr/sap/BD1/SYS/global/sltools/sharedlib/tc_ sec_secstorefs.jar:/oracle/client/10x_32/instantclient/ojdbc14.j ar
    -sec
    BD1,jdbc/pool/BD1,/usr/sap/BD1/SYS/global/security /data/SecStore.properties,/usr/sap/BD1/SYS/global/ security/data/SecStore.key
    -dataDir /oracle/expocopy/JAVA/JDMP -remove_trailing_blanks
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/removeTrailingBlanks.txt
    -convert_empty_LOBs
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyLobs.txt
    -convert_empty_strings
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyStrings.txt
    -convert_empty_binary
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyBinary.txt'
    aborts with return code 1.<br>SOLUTION: Check 'jload.log' and
    '/tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/jload.java.log'
    for more information.
    Log details for jload.java.log:
    java version "1.4.2_12"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_12-b03)
    Java HotSpot(TM) Client VM (build 1.4.2_12-b03, mixed mode)
    Oct 15, 2010 10:32:33 AM com.sap.inst.jload.Jload main
    INFO: Jload -sec
    BD1,jdbc/pool/BD1,/usr/sap/BD1/SYS/global/security /data/SecStore.properties,/usr/sap/BD1/SYS/global/ security/data/SecStore.key
    -dataDir /oracle/expocopy/JAVA/JDMP -remove_trailing_blanks
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/removeTrailingBlanks.txt
    -convert_empty_LOBs
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyLobs.txt
    -convert_empty_strings
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyStrings.txt
    -convert_empty_binary
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/convertEmptyBinary.txt
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.DBConnection
    connectViaSecureStore
    INFO: connected to BD1 on jdbc/pool/BD1
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.ExcludedObjects addObjects
    INFO: excluded objects (type TB): [EP_ATTR_HEADERS, EP_ATTR_VALUES,
    J2EE_CONFIGENTRY]
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.ExcludedObjects addObjects
    INFO: excluded objects (type EL): [EP_ATTR_HEADERS, KMC_DBRM_CONTENT,
    EP_ATTR_VALUES, J2EE_CONFIGENTRY]
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.ExcludedObjects addObjects
    INFO: excluded objects (type ES): [EP_ATTR_HEADERS, KMC_DBRM_CONTENT,
    BC_SCVERSION, J2EE_CONFIGENTRY]
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.ExcludedObjects addObjects
    INFO: excluded objects (type EB): [KMC_DBRM_CONTENT, J2EE_CONFIGENTRY]
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.JobStatus readStatus
    INFO: trying to read status file
    /tmp/sapinst_instdir/NW04S/LM/COPY/ORA/EXP/CENTRAL/ AS/EXP/EXPORT.sta
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.JobStatus readStatus
    INFO: commencing restart
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.Jload dbExport
    SEVERE: DB Error during export of CAF_GP_IF_CONTEXT
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.Jload printSQLException
    SEVERE: Message: ORA-00942: table or view does not exist
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.Jload printSQLException
    SEVERE: SQLState: 42000
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.Jload printSQLException
    SEVERE: ErrorCode: 942
    Oct 15, 2010 10:32:35 AM com.sap.inst.jload.db.DBConnection disconnect
    INFO: disconnected

  • Print PDF file with the lay out created in the BEx web application designer

    Got the following questions (problems) when print a web report created in BEx Web Application Designer to a PDF file:
    1. The tile (which has a company logo and report name in it) was not printed, is it possible to print a title (with company logo) on each page of the PDF file?
    2. Want print the filters that have value specified on the PDF file, is it possible to do this?
    Any help is appreciated, thanks.

    Hi Simon,
    you can achieve this requirement i.e. using this way of implementation:
    1. Create a new template which contains the required fields (company logo etc) and set the visibility of the top container to "hidden". Add a empty data provider to this template and add the filter values (variable names) you want to display on the PDF. However be aware that the name for the (empty) data provider must match the name of the data provider within the original template you want to print.
    2. Open your original template and include the template you created in step 1 (Advanced: Web Templates). Choose the appropriate location (above/below the analysis item.
    3. Check the settings of your export command: do not set a special web item to be printed.
    If you export the template within web the second template should be printed correctly.
    Brgds,
    Marcel

  • Create Refinement topics for web application in SharePoint 2013 Search

    
    Is there a way we can add available web application name in refinement panel in SharePoint 2013 search. there is a search called Enterprise search which is named as Everything, that search from all the web applications available. is there a way we can have
    a search refinement panel which is the list of web applications so that it allows us to filter the results by web application.
    can we add a refinement panel like below  in SharePoint Search 2013
    here is an image for 
    kukdai

    Hi kukdai,
    To use result source or query rule to distinguish search results, besides adding custom search vertical, you could also consider using result block:
    http://blogs.technet.com/b/mspfe/archive/2013/02/01/how-query-rules-and-result-sources-can-be-used-to-customize-search-results.aspx
    http://www.sharepoint2013.me/Blog/Post/261/SharePoint-2013---Create-and-display-results-blocks
    Quote:
    In SharePoint, result block will display the search results as a group. We can promote result block depending on the query condition as specific result. While configuring query conditions for results block, we can use query variables. We can specify query
    variables as place holders for unknown values in SharePoint query.
    Then we can use Path in query rule to divide search results into several web applications.
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Create  PCD folder using web dynpro Java

    Hi All ,
    I would like to create pcd folder structure using web dynpro java
    i.e. My folder at top level and under this there will be iviews , roles , worksets  etc.
    Is it possible using WDJ ?
    I have checked the below link , but for folders I did not get anything.
    http://help.sap.com/saphelp_nw04/helpdata/en/44/6aaf92f5a23672e10000000a114a6b/frameset.htm
    Can you please help me ?
    Thanks,
    Sandip

    Hi,
    Please refer to the following document
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/508baf88-9335-2d10-efa6-c6ad61e5fc4b?quicklink=index&overridelayout=true
    The same can be implemented in webdynpro also.
    Regards,
    Raju Bonagiri
    Edited by: Raju Bonagiri on Sep 3, 2010 8:36 AM

  • Create Public Part for Web Application

    Hi all,
    I'm migrating a now Development Component Web Application to DC Web Application. When it was done, the Public Parts isn't created automatically, in according with documentation.
    So I'm creating a Public Part with name war, but I'm changing the file manually to include the Entity Reference to Web Module.
         <entities>
              <entity>
                   <name>demo.sap.comtestweb~module</name>
                   <entity-type>WAR</entity-type>
              </entity>
         </entities>
    Today, through NWDS i can't  to set this reference on Development Infrastructure.
    Does anybody know if the only way to create this entity reference is manually?
    Best regards

    Chances are bigger of finding a solution in the NWDI forum. Moving it there...
    \-- Vladimir

  • Need to create setup (.exe) for web application

    Hi,
    I have Web application based on SharePoint 2010 and that contains three site collection,custom web part ,site,sub site,,,etc I need to deploy it from development environment to production environment
    How I can create setup file (.exe) to deploy Web application in production environment ?
    Thanks in advance,
    sathya

    Hello sathya,
    Already replied in this thread. It seems both are duplicate threads but created by different accounts.
    http://social.msdn.microsoft.com/Forums/en-US/0435c2d5-8a8f-4df2-967b-69c044c1be23/creating-exesetup-for-sharepoint-2010-web-application-using-visual-studio-2010?forum=sharepointadminprevious
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Web Application directory structure

    Please can someone help me with directing me to any online guide as to how webapp could be created and web.xml configuration in Sun Application server 8.
    I do not understand the directory structure of sun, unlike Tomcat the webapps contains all the virtual context part with a default ROOT direct set in the server.xml as the default docbase.
    Now, where is the default ROOT in Sun server? Where can I put my index file. When I create a web context, where will I put it? Does J2EE has similar WEB-INF structure in Tomcat? Does it have web.xml to configure the webapp
    Finally, I have written a simple EJB called Hello World using stateless protocol. I have my Hello.class, HelloHome.class and HelloBean.class. I also have ejb-jar.xml for container configuration. I have jar then up to hello.jar and have deployed them. Now I want to access the beans, Home bean to be precises. I have written a hello.jsp and I put it in the orignal directory where the main index.html file is in Sun server which is /user/Sun/AppServer/domains/domain1/docroot, I got errors.
    Could someone shade a light on this please.
    Thanks Guys.
    NB
    Do not point me to online reference
    I have awared max point for this question

    The developer's guide discusses in pretty clear terms how to deploy a J2EE app from a directory structure.
    The tomcat directory structure is really the same as a packaged war which once you read the documentation you will see is basically no different with SJSAS.
    You need to deploy an application. See previous posts on how to have docroot be the top level (search for posts by janluehe)

  • How to create a folder with java application?

    Hi expert
    I would like to read some tutorial or manual to understand the logic behind the management of the folder and document from a java application in KM.
    Anyone could help me?
    thank you
    Andrea

    Dear Andrea,
    Please have a look to below documents might help.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30a2a087-190f-2d10-07a4-dad666b44c1f?QuickLink=index&overridelayout=true
    http://wiki.sdn.sap.com/wiki/display/Snippets/KMLibrary-ReusableComponentforWebDynpro+Java
    Best Regards,
    Arun Jaiswal

  • How to create an event in web application?

    Hi,
    I am creating online auction application. I need to have an event trigerred when an auction on an item is finished. How can I do that?
    Thank you

    You could use the Observer design pattern...You'll find plenty of litterature on the subject.
    You'd also want to take a look at how they implement the feature you're looking for in existing auction applications, like Sun's :
    http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/code.html
    Sourceforge's Gavel, which is open source, so you can browse the CVS repository to look for source code :
    http://sourceforge.net/projects/gavel/

  • Creating a Map in Web Application Designer

    I was wondering what I need to create a map in WAD.  Do you have to use the ArcView GIS software for the map to work correctly?  Any information you have on configuring this is greatly appreciated.

    Hi MAC,
    1) 0country is itself content world map, So you can use it for demo purpose.
    After installing 0country from business content
    Then please check 0country contains MAPS
    RSD1 -- 0Country
    Click on Maintain
    Click Business Explorer
    Under BEx Map please click on Edit shape files
    It's contain three Objects- BW_GIS_DBF, BW_GIS_SHP, BW_GIS_SHX
    These three files confirms itself that Geographic data.
    2) ESRI is providing only GIS software for processing MAPs (Which contains some free demo maps).
    Use following link for Ordering ESRI product
    http://gis.esri.com/special/sap/voucher.cfm
    Thanks & Regards,
    Sushant N. Tiwarekar
    SAP Consultant

Maybe you are looking for