Access files from servlet

hi
how can i access a local text file using a servlet.

Presumably by "local" you mean a file on the server where the servlet is running? If so, you do what you would normally do in a Java program to access a local file. If by "local" you mean a file on some other system, which would be a bizarre meaning of the word, then the rules are the same as for any other Java program: that other system has to have a server running, and your servlet has to access it via that server.

Similar Messages

  • Access EJB from Servlet that in different archive?

    <font class="mediumtxt">package kyro.ejb.session;
    import javax.ejb.*;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless(name="StandAlone")
    @Remote(StandAlone.class)
    public class StandAloneBean
    implements StandAlone, StandAloneLocal
    public StandAloneBean() {
    public String sayHello() {     
    return "sayHello";
    I want to access ejb from servlet that .war and .jar not in single .ear. I want to try that just with annotation not xml descriptor cause is easy to understand for me. I use Glassfish. But i can't lookup that ejb. How can i lookup that ejb with jndi? Can't you give me example of servlet to access that? I not use JNDI.properties, are that caused i can't access my ejb? I just thing .war and.jar in one server, are i have to used JNDI.properties. can you explain how to use JNDI.properties in servlet or separate file?
    </font>

    But i can't lookup that ejb. How are you trying and what exception is occurring?
    How can i lookup that ejb with jndi? [https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html|https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html]
    m

  • How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; I also have Microsoft Word installed on the Mac as well.

    How can I access files from a flash drive that were previously saved using a Windows computer? When I attempt to open the file on MacBook Pro, it is asking to "convert file to"; none of the options I choose work. I also have Microsoft Office (with Word) installed on the Mac as well.

    Format the external drive as FAT32 or ExFAT. Both computers will then be able to read and write to it.

  • Is there any way to access files from the Classic environment to my iMac running on Leopard (10.5.8)?

    Is there any way to access files from the Classic environment to my iMac running on Leopard (10.5.8)?

    Sorry, no.

  • How to call any .tmpl file from servlet by sending some parameters ?

    Hi,
    I am new to Java Servlet and HTML template language ( anyfile.tmpl).
    I have created simple login authentication with user registration for new user.
    If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
    Thank you.
    if (session == null) {
         try {
              userName = request.getParameter("login");
              pwd = request.getParameter("password");
              if (!userName.equals("") && !pwd.equals("")) {
              try {
    //Database connection, data fetching, query execution etc.
    // code will go here
                   while (rs.next()) {
                   if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
                        String u_name = userName;
                        String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
                        String address = rs.getString("address");
                        session = request.getSession();
                        session.setAttribute("user", userName);
                        String inbox = context.getInitParameter(INBOX);
                        Template inboxTmpl = new Template(inbox);
    *                    inboxTmpl.setParam("userName", u_name);*
    *                    inboxTmpl.setParam("ph_no", ph_no);*
    *                    inboxTmpl.setParam("address", address);*
    *                    out.println(inboxTmpl.output());*
                        System.out.println("Login successful..");
                        break;
                   rs.close();
         pstmt.close();
    con.close();
    (P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}

    Where does Template come from?
    But its not working.The other day I called the car repair shop. I told them my car did not work and I wanted them to fix it. They asked what was wrong, whether it did not start, whether suspicious sounds were heard, whether the car did not want to brake any longer, whether it gave a smoke from the exhaustion, whether the wind shield was broken, whether the oil was leaking etc. But I insisted just telling them "it doesn't work".

  • Creating Folder and Accessing Files from Folders in mobile phone

    Hello Friends,
    I am doing my project where I need to create folders and accessing files from those folders in java enabled mobile phones.But I do not know the required tasks for this.Any type of help is highly appreciated.
    Greeting
    Saadi

    You have to get the classname of the Items you receive from getitems.
    There you have only to look for Folder.CLASS_NAME. Example:
    ifsFol sorted by names in ascending order (names of folders and files)
    String[] sort_attributes = {"NAME"};
    //sort will be ascending
    boolean [] sort_orders = {true};
    oracle.ifs.common.SortSpecification sort = new oracle.ifs.common.SortSpecification(sort_attributes, sort_orders);
    ifsFol.setSortSpecification(sort);
    PublicObject[] contents = ifsFol.getItems();
    System.out.println("Here are the names of the items in folder: ");
    for (int i=0; i < contents.length; i++) {
    if (contents.getClassname().equals(Folder.CLASS_NAME)) {
    System.out.println(contents[i].getName());
    null

  • How do you access files FROM a home network TO a CLIENT computer using "internet sharing" from a mac ?

    Hi.
    I just created a small network: 2 pcs and 1 mac.
    2 pcs are using windows XP
    1 Mac is using OS X
    I would like to know how to access files from my pc1 to pc2 from my network.
    Pc2 obviouslys is a client behind the intenet sharing my mac is providing.
    I tried looking for the info online but most of the search brigns out "internet sharing" or "file sharing."
    Any help would be great.

    The following may help with the file sharing issues: OS X Mavericks: Share your files

  • I own a print company have room of puters and a older server- i want my mac and pc people to access files from anywhere without using an aftermarket program

    can I get this 5 license server - 2012, and me from home or road or artist from home or road got to an ip addy and have access to our 1.2 tb of customer files to edit after hours or fix or pull for meeting, do I need a real servr or can u use a computer
    with 1tb had drive and a 2tb plug in dive to access files from anywhere on mac or pc and network all y shop and pull files from anywhere so I don't need a wlan but have an all time go to place to get files-- it will be on 24/7 with battery backup- I need to
    get up to date and tonite had to drive to work to pull a file I could have I think gotten with this software-- can anyone help or explain am I getting right thing and will it work its 3 am and I am just back from work, I could have been done at 9 if I have
    a server access--THANKS IS ADVANCE--TECH LEVEL- COMPARED TO YOU GUYS A 1- IN GENERAL A 3-4
    THANKS

    Hi,
    I'm not very clear about the exact requirement.
    I assume you would like to:
    1. Able to access a share in company from anywhere.
    2. Above to use a server from anywhere.
    3. Above to use a server in your company from anywhere.
    If I'm correct, the solution is Could products or Remote Desktop Service with VPN.
    Please refer to Windows Azure to see if a cloud server could help in this situation.
    http://azure.microsoft.com/
    Also you can use OneDrive to store files on cloud side and you can access it from anywhere.
    And for VPN please refer to this article:
    Configure a Remote Access VPN Server
    http://technet.microsoft.com/en-us/library/cc725734(v=ws.10).aspx
    Let us know the one you prefer and we could discuss it more. 
    If you have any feedback on our support, please send to [email protected]

  • Access files from Web Dynpro component

    Hi,
    I need to access files from a Web Dynpro component but I couldn't find any information. Has anyone done this?
    My questions are:
    1. Can I pack these files into the WD component so they can be deploy together?
    2. And what API should I use to access these files?
    Thanks,
    Kizza

    Hi,
    You can follow the Creating the JCO connections in the Content Administrator section in the following
    help.sap.com [link|http://help.sap.com/saphelp_nw70/helpdata/EN/f8/bdfe80d9a3b048a5fb32a7d149774e/content.htm].
    For the RFC_ERROR_COMMUNICATION error, you can check if the system sapmsR3D is defined in your
    SAP Logon pad or in the hosts file under Drivers -> etc folder.
    Regards,
    Alka.

  • Call batch file from Servlet.

    Hi all,
    can anybody tell me how to call or run batch file
    from Servlet.
    Please do hurry.

    class RuntimeClass
    public static void main(String str[]){
    Runtime JVM = Runtime.getRuntime();
              try
                   JVM.exec("abc.bat");
              catch(Exception e)
                   System.out.println("hello");
    Hi,
    i hope the above program will help.

  • JDBC + SERVLET: inserting text data  to access file from Html form

    Hi everybody !
    I'm trying to insert text data from my html form to access database using servlet and jdbc technologies.
    The problem that I'm that the data is TEXT, but not the English language !!!
    So my access db file gets - ???????? symbols instead the real text.
    This is the form line that sending data to my servlet:
    <form
    method="POST"
    ACTION=http://localhost:8080/servlet/myServlet enctype="text/html">
    And this is servlet line that defines response content:
    res.setContentType( "text/html" );
    What can I do to get in access db file the right text format and not a ???????? symbols.
    Maybe I must to ad some <meta ...> , but where ?

    You're dealing with Unicode, I'd guess, and not ASCII.
    I guess I'd have two questions:
    (1) Is the character encoding on your pages set properly for the language you're trying to use?
    (2) Does Access handle Unicode characters?
    Access isn't exacly a world-class database. (If it was, there'd be no reason for M$ to develop SQL Server.) I'd find out if it supports other character sets. If not, you'll have to switch to a more capable database that does. - MOD

  • Can not get access files from Windows 7 to Claims-based file authorization share

    We have AD level 2012R2, DCs running 2012R2 of course, and we have clustered File Server (3 FSNodes running 2012R2).
    We enabled 2 policies 
    KDC Support for claim
    Kerberos support for claim
    We created 1 claim type in ADAC (For example "Division" Source Property). Filled this property to all IT AD Accounts by our value "IT"
    On FS made a share folder ITDivision:
    - set permissions  Domain Users can Modify if User.Division equals "IT"
    so on Windows 8 IT Users can access files on this share and on Windows 7 they cant
    =\ . We know from many presentations about Dynamic Access Control that File Server must enroll user claims if client do not support this claims (Service-for-User-To-Self)

    Hi,
    >>so on Windows 8 IT Users can access files on this share and on Windows 7 they cant
    =\ . We know from many presentations about Dynamic Access Control that File Server must enroll user claims if client do not support this claims (Service-for-User-To-Self)
    How is it going? Was there any error message? As far as I know, Dynamic Access Control (DAC) should work for downlevel clients. It’s backwards compatible. As Florain explains in the following blog:
    For non-Windows 8 and non-Windows Server 2012 boxes accessing DAC-protected file shares, the users do not carry any claims. For them, the Server 2012-based file share will query Active Directory and proxy the claims request to figure out what claims
    the user and machine bring. The file server checks in the name of the user, whether they should have claims. With that information, the file server evaluates the access to the file share. So yeah – DAC works for downlevel clients, too. It’s backwards compatible.
    And totally transparent to Windows 7.
    Questions regarding Dynamic Access Control (FAQ)
    http://www.frickelsoft.net/blog/?p=293
    In addition, regarding dynamic access control, the following blog can also be referred to for more information.
    Dynamic Access Control in Windows Server 2012
    http://www.infoq.com/news/2012/10/Dynamic-Access-Control
    Please Note: Since the above two website are not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Best regards,
    Frank Shen

  • Cannot access file from JApplet

    I have used the swingall.jar file with my JApplet for any
    version of IE. It gives one error
    i.e
    Cannot access file c:\prog\project
    I want to create a directory within c:\prog and also i want
    to write some files there. Pls help me.

    try this my friend!
    1.     Compile the applet
    2.     Create a JAR file
    3.     Generate Keys
    4.     Sign the JAR file
    5.     Export the Public Key Certificate
    6.     Import the Certificate as a Trusted Certificate
    7.     Create the policy file
    8.     Run the applet
    Susan
    Susan bundles the applet executable in a JAR file, signs the JAR file, and exports the public key certificate.
    1.     Compile the Applet
    In her working directory, Susan uses the javac command to compile the SignedAppletDemo.java class. The output from the javac command is the SignedAppletDemo.class.
    javac SignedAppletDemo.java
    2.     Make a JAR File
    Susan then makes the compiled SignedAppletDemo.class file into a JAR file. The -cvf option to the jar command creates a new archive (c), using verbose mode (v), and specifies the archive file name (f). The archive file name is SignedApplet.jar.
    jar cvf SignedApplet.jar SignedAppletDemo.class
    3.     Generate Keys
    Susan creates a keystore database named susanstore that has an entry for a newly generated public and private key pair with the public key in a certificate. A JAR file is signed with the private key of the creator of the JAR file and the signature is verified by the recipient of the JAR file with the public key in the pair. The certificate is a statement from the owner of the private key that the public key in the pair has a particular value so the person using the public key can be assured the public key is authentic. Public and private keys must already exist in the keystore database before jarsigner can be used to sign or verify the signature on a JAR file.
    In her working directory, Susan creates a keystore database and generates the keys:
    keytool -genkey -alias signFiles -keystore susanstore -keypass kpi135 -dname "cn=jones" -storepass ab987c
    This keytool -genkey command invocation generates a key pair that is identified by the alias signFiles. Subsequent keytool command invocations use this alias and the key password (-keypass kpi135) to access the private key in the generated pair.
    The generated key pair is stored in a keystore database called susanstore (-keystore susanstore) in the current directory, and accessed with the susanstore password (-storepass ab987c).
    The -dname "cn=jones" option specifies an X.500 Distinguished Name with a commonName (cn) value. X.500 Distinguished Names identify entities for X.509 certificates.
    You can view all keytool options and parameters by typing:
    keytool -help
    4.     Sign the JAR File
    JAR Signer is a command line tool for signing and verifying the signature on JAR files. In her working directory, Susan uses jarsigner to make a signed copy of the SignedApplet.jar file.
    jarsigner -keystore susanstore -storepass ab987c -keypass kpi135 -signedjar SSignedApplet.jar SignedApplet.jar signFiles
    The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
    5.     Export the Public Key Certificate
    The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
    The -storepass ab987c and -keystore susanstore options specify the keystore database and password where the private key for signing the JAR file is stored. The -keypass kpi135 option is the password to the private key, SSignedApplet.jar is the name of the signed JAR file, and signFiles is the alias to the private key. jarsigner extracts the certificate from the keystore whose entry is signFiles and attaches it to the generated signature of the signed JAR file.
    5: Export the Public Key Certificate
    The public key certificate is sent with the JAR file to the whoever is going to use the applet. That person uses the certificate to authenticate the signature on the JAR file. To send a certificate, you have to first export it.
    In her working directory, Susan uses keytool to copy the certificate from susanstore to a file named SusanJones.cer as follows:
    keytool -export -keystore susanstore -storepass ab987c -alias signFiles -file SusanJones.cer
    Ray
    Ray receives the JAR file from Susan, imports the certificate, creates a policy file granting the applet access, and runs the applet.
    6.     Import Certificate as a Trusted Certificate
    Ray has received SSignedApplet.jar and SusanJones.cer from Susan. He puts them in his home directory. Ray must now create a keystore database (raystore) and import the certificate into it. Ray uses keytool in his home directory /home/ray to import the certificate:
    keytool -import -alias susan -file SusanJones.cer -keystore raystore -storepass abcdefgh
    7.     Create the Policy File
    The policy file grants the SSignedApplet.jar file signed by the alias susan permission to create newfile (and no other file) in the user's home directory.
    Ray creates the policy file in his home directory using either policytool or an ASCII editor.
    keystore "/home/ray/raystore";
    // A sample policy file that lets a JavaTM program
    // create newfile in user's home directory
    // Satya N Dodda
    grant SignedBy "susan"
         permission java.security.AllPermission;
    8.     Run the Applet in Applet Viewer
    Applet Viewer connects to the HTML documents and resources specified in the call to appletviewer, and displays the applet in its own window. To run the example, Ray copies the signed JAR file and HTML file to /home/aURL/public_html and invokes Applet viewer from his home directory as follows:
    Html code :
    </body>
    </html>
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    width="600" height="400" align="middle"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,1,2">
    <PARAM NAME="code" VALUE="SignedAppletDemo.class">
    <PARAM NAME="archive" VALUE="SSignedApplet.jar">
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    </OBJECT>
    </body>
    </html>
    appletviewer -J-Djava.security.policy=Write.jp
    http://aURL.com/SignedApplet.html
    Note: Type everything on one line and put a space after Write.jp
    The -J-Djava.security.policy=Write.jp option tells Applet Viewer to run the applet referenced in the SignedApplet.html file with the Write.jp policy file.
    Note: The Policy file can be stored on a server and specified in the appletviewer invocation as a URL.
    9.     Run the Applet in Browser
    Download JRE 1.3 from Javasoft
    save this to write.jp
    keystore "/home/ray/raystore";
    // A sample policy file that lets a JavaTM program
    // create newfile in user's home directory
    // Satya N Dodda
    grant {
    permission java.security.AllPermission;
    save this to signedAppletDemo.java
    * File: @(#)SignedAppletDemo.java     1.1
    * Comment:     Signed Applet Demo
    * @(#)author: Satya Dodda
    * @(#)version: 1.1
    * @(#)date: 98/10/01
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.io.*;
    import java.awt.Color;
    * A simple Signed Applet Demo
    public class SignedAppletDemo extends Applet {
    public String test() {
    setBackground(Color.white);
         System.out.println(System.getProperty("user.home"));
         String fileName = System.getProperty("user.home") +
                        System.getProperty("file.separator") +
                        "newfile";
         String msg = "This message was written by a signed applet!!!\n";
         String s ;
         try {
         FileWriter fos = new FileWriter(fileName);
         fos.write(msg, 0, msg.length());
         fos.close();
         s = new String("Successfully created file :" + fileName);
         } catch (Exception e) {
         System.out.println("Exception e = " + e);
         e.printStackTrace();
         s = new String("Unable to create file : " + fileName);
         return s;
    public void paint(Graphics g) {
    g.setColor(Color.blue);
    g.drawString("Signed Applet Demo", 120, 50);
    g.setColor(Color.magenta);
    g.drawString(test(), 50, 100);

  • How to access file from AIX server

    Hi ,
    I am facing a problem with Aix Machine .
    I want to access the file from AIX server machine .I am in Windows machine.
    Regards
    Raghava

    HI all,
    My question is how to represent file folder name of that server
    my file folder in AIX server and i want to access that file in window s machine.
    * is this the right way to represent the data folder in physical schema declaration
    file:///<aix server IP>/usr/oracledi/oracldi/data
    Regards
    Raghava
    Message was edited by:
    Raghava.java

  • Can't access files from one account to another on same Mac

    I've got a new macbook and I've divided it into two accounts. One account has all my iTunes music but the other is a fresh iTunes with no music.
    I've been trying to get access to the music from the other account. It seems like it should be easy as it's already on this computer. I've tried copying the iTunes folder into the public folder and going to the other account and copying it to it but that's not working.
    I've also tried sharing the files from the Sharing sys prefs. But can't get that to work. And I've also put the Music folder into the Shared folder and still nothing.
    The folders I need have the red minus on them.
    I must be missing something simple. Help!
    Thanks.

    wireduck,
    Highlight the music folder and on the keyboard type (Command) + i: on the window that opens scroll down if need and click on the lock on the bottom right. Type in an Admin User name and password. Then under the (Sharing & Permissions:) make sure the users you want to open the folder are listed and that there (Privilege) is set to @ least Read. If not hit the ( + ) sign and add them. After you have that all set up click on the little gear next to the ( - )s sign and (Apply to a enclosed items). that way each user can read the files. After that the little ( - ) sign should be gone on the folders.
    Hope that helps.

Maybe you are looking for

  • Oracle 8i Enterprise Install Error

    I installed (successfully) Oracle 8i Enterprise edition on my NT 4.0 SP5. I then confused matters by installing Oracle 7.3.4 Enterprise Manager on the same machine. Realizing I made a mistake - I tried to uninstall Enterprise Manager - but got a LOT

  • Problem Setting up lion OD Replica

    Dear Community, i have some big troubles in setting up the Open Directory Replication to another mac mini i7 Lion Server. The directory was set up on the first mac mini i7 Lion Server without any problems. It's possible to join the directory from ano

  • How to render outputlink as an area tag rather than an a tag

    Hi all, As stated in JSF document, both shape and coords are valid properties in outputlink. So, I have tried following <map name="monkey"> <h:outputLink shape="rect" coords="0,0,30,30" value="http://yahoo.com"/> </map> however. that is rendered as <

  • Found a bug in the Convert widget how to report ?

    Hello, i found a bug in the default convert widget delivered by apple, how can i let them know if this bug ? (it's not crashing, it's a big calculation error) Thanks,

  • New to LDAP

    hi, im working on a login application , that is in struts and i have to use LDAP in that ... i m very new to LDAP....i dont know anything.........pls can any one help me.? can u pls give me one simple code example of LDAP. thanks