Reading from servlets (where from)

Hi i would like to read in a text file from my servlet, but i do not know where i should place the file i whish to read in. please could you tell me where i need to place the file to get it to read in and anthing special i need to do to get it to read in.

The first reply can be used without packages.However you should put your servlet in a package. In
fact for the servlet containers (Tomcat etc.) that are
being produced today, you must put your servlet in a
package.But the text file the servlet reads doesn't have to be in a package.

Similar Messages

  • Using servlets to read from text file and insert data

    Hi,
    Can I use a servlet to read from a space delimited text file on the client computer and use that data to insert into a table in my database? I want to make it easy for my users to upload their data without having to have them use SQL*Loader. If so can someone give me a hint as how to get started? I appreciate it.
    Thanks,
    Colby

    Create a page for the user to upload the file to your webserver and send a message (containing the file location) to a server app that will open the file, parse it, and insert it into your database. Make sure you secure the page.
    or
    Have the user paste the file into a simple web form that submits to a servlet that parses the data and inserts it into your db.

  • Help: Servlet can't read from properties file

    I am working on a web application running in Tomcat on Linux.My java source file reads some parameters from a properties file (data.properties)in the same directory. This works well in a simple application. However, if it is used in the Tomcat environment, it can't be read by a servlet file (LoginServlet.java). I put both the "LoginServlet.class" and "data.properties" in the following directory: /webapps/myapp/WEB-INF/classes. When I run the web application in Tomcat, the error is "data.properties not found". What is the problem? Do I need to modify my "web.xml" and/or Tomcat's "server.xml"? If so, how to modify them?
    This web application contains a lot of serlets. So I don't want to hardcode the parameters into the servlet codes.
    Any info will be appreciated. Thanks in advance!:)

    Putting the properties file in webapps/myapp may or may not help.
    My assumption is that you are trying to open the file by brute force, with something like
    InputStream propis = new FileInputStream ("data.properties");
    Properties props = new Properties ( );
    props.load (propis);
    What you want is to have the class loader find a file in the same place as the class file, and give you back an input stream reading from that file, which you can then pass to the Properties.load(InputStream) method. This is called a "resource," and the way to do it is:
    InputStream propis = getServletContext().getResourceAsStream("data.properties");
    // remaining code as above
    This will cause the class loader for the servlet context (a/k/a the Web application) to find the file in the same manner as it might find a class, but instead of treating it as compiled JVM code, and loading it, it simply passes you back an InputStream from which you do whatever you want.
    Cheers!
    Jerry Oberle
    perl -e 'printf "mailto%cg%s%cearthlink%cnet\n", 58, "oberle", 64, 46;'

  • Where is the Disable Read from Cache option ?

    I'm running Zenworks for desktops 4 and zenworks for servers 3 and I would
    like to try out the option Disable Read from Cache, but I'm unable to find
    it anywhere in the user or OU property pages.
    Where is it?
    Thanks!
    Oliver

    On Wed, 13 Dec 2006 08:03:17 GMT, [email protected] wrote:
    > Where is it?
    application launcher configuration
    Marcus Breiden
    If you are asked to email me information please change -- to - in my e-mail
    address.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • Where to place    text file in  Jdeveloper9irc  to read from Java program

    For ex.
    package mypackage;
    import java.io.*;
    public class ReadData
    public ReadData()
    public static void main(String[] args)
    new ReadData();
    try{
    File fin = new File("test.txt");
    if (fin.canRead())
    System.out.println("Can read file");
    I am geting a error message of file not found. Please advise
    in which directory should I place the text file "test.txt" so that the java program can read from it.
    Thanks,
    agsp

    The test.txt file should be in the 'Run Directory" of your Project. Select Project.jpr and invoke Project settings dialog.
    Click on the Runner. You will see the "Run Directory" edit field.
    For ex.
    package mypackage;
    import java.io.*;
    public class ReadData
    public ReadData()
    public static void main(String[] args)
    new ReadData();
    try{
    File fin = new File("test.txt");
    if (fin.canRead())
    System.out.println("Can read file");
    I am geting a error message of file not found. Please advise
    in which directory should I place the text file "test.txt" so that the java program can read from it.
    Thanks,
    agsp

  • I cannot display image (read from oracle BLOB field) on browser?

    I cannot display image (read from oracle BLOB field) on browser?
    Following is my code, someone can give me an advise?
    content.htm:
    <html>
    <h1>this is a test .</h1>
    <hr>
    <img  src="showcontent.jsp">
    </html>showcontent.jsp:
    <%@ page import="com.stsc.util.*" %>
    <%@ include file="/html/base.jsp" %>
    <% 
         STDataSet data = new STDataSet();
    //get blob field from database     
         String sql = "SELECT NR FROM ZWTAB WHERE BZH='liqf004' AND ZJH='001'";
         //get the result from database
         ResultSet rs = data.getResult(sql,dbBase);
         if (rs!=null && rs.next()) {
              Blob myBlob = rs.getBlob("NR");
              response.setContentType("image/jpeg");//
              byte[] ba = myBlob.getBytes(1, (int)myBlob.length());
              response.getOutputStream().write(ba);
              response.getOutputStream().flush();
         // close your result set, statement
         data.close();     
    %>

    Don't use jsp for that, use servlet. because the jsp engine will send a blank lines to outPutStream corresponding to <%@ ...> tags and other contents included in your /html/base.jsp file before sending the image. The result will not be treated as a valid image by the browser.
    To test this, type directly showcontent.jsp on your browser, and view it source.
    regards

  • Can write, can't read from SSLSocket. No trusted certificate found

    Hello!
    We have to use an ssl connection to talk to another application. The exception is generated when trying to read from the socket. Creation and writing don't generate any errors and I can't verify if the other server actually gets what I'm writing.
    I used these commands to create the private key and the certificate
    openssl genrsa -des3 -out priv.pem -passout pass:myPassword 1024
    openssl req -x509 -new -key priv.pem -passin pass:myPassword -days 3650 -out cert.cerI have imported the cert.cer into the java/jre/lib/security/cacerts keystore. The CN value in the cert.cer is the one I got from the hostname command.
    I still get the error:
    javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: No trusted certificate foundJust before reading from the socket I print in the log file the sockets properties:
    is input shut down? false
    is output shut down? false
    is bound? true
    is closed? false
    is connected? trueAm I suppose to do somethin with the priv.pem? Where does that one go? Isn't the cert.cer enough?
    I don't know what else to do and how to check anything else. Any ideas would be greatly appreciated.
    Thank you very much,
    Iulia S.

    Hi again,
    I am at wits' end in here and I hate it when I move in the unstable grounds of not knowing stuff. I am still getting the error.
    I managed to get the certificate from the other application, it's not self-signed it's issued by Thawte. Apparently you can also get it with FF3 from the cute little lock next to the address bar. Am I talking about the same certificate? Then I did this to import it:
    ./keytool -import -alias bristow -file /location/to/THEcertificate -keystore /location/to/java/jre/lib/security/cacertsAnd I did restart the server. Several times. Several several times.
    Some details about the application: it's a servlet running on a websphere 6.1 server. I noticed that this error is from sun.security.validator.ValidatorException while mine is from:
    javax.net.ssl.SSLHandshakeException: com.ibm.jsse2.util.h: No trusted certificate foundI can understand they are different packages but shouldn't they implement the same standard protocol? btw there are no com.sun.* classes imported.
    Am I not creating the SSLSocket right?
    SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket s = (SSLSocket) sslsocketfactory.createSocket("secureSite.com", portNo);The string that defines the hostname, it's just the name, no protocol or anything else, right? I just need someone to confirm it. I've already tried all the other posibilities and they don't work.
    It all crashes at the readLine:
    BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
    String input = "";
    while((input = in.readLine()) != null)I ran the php script they gave us as an example, on a different server, and it worked just fine. No certificates needed.
    I've tried reading characters instead of line, just in case this error would be absurdly linked with the no-end-of-line. Same error.
    I'm trying to poke the server with a stick see if I can get a response. I run this from my local machine:
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.PrintWriter;
    import java.net.URLEncoder;
    import java.util.Date;
    import javax.net.ssl.SSLSocket;
    import javax.net.ssl.SSLSocketFactory;
    public class EchoClient
         public static void main(String[] arstring)
              try
                   SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
                   SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("hostname", 99999);
                   sslsocket.setEnabledCipherSuites(sslsocket.getSupportedCipherSuites());
                   StringBuffer data = new StringBuffer();
                   dataDeTrimis.append("DATA1=").append(URLEncoder.encode("DATA1","UTF-8"))
                   .append("&DATA2=").append(URLEncoder.encode("DATA2", "UTF-8"));
                   String includeHeader = "POST /script/location/script.php HTTP/1.1\r\n" + "Content-Length: " +        data.length() + "\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "\r\n" + data;
                   BufferedReader in = new BufferedReader(new InputStreamReader(sslsocket.getInputStream()));
                   PrintWriter outs = new PrintWriter(sslsocket.getOutputStream(), true);
                   outs.print(includeHeader);
                   String input = "";
                   System.out.println("is input shut down: "+sslsocket.isInputShutdown()+" is output shut down? "+sslsocket.isOutputShutdown()+" is bound? "+sslsocket.isBound()+" is closed? "+sslsocket.isClosed()+" is connected? "+sslsocket.isConnected());
                   System.out.println("server: "+in.read());
                   while((input=in.readLine())!=null)
                        System.out.println("SERVER REPLIED : " + input + "\n");
                   sslsocket.close();
              catch(Exception exception)
                   exception.printStackTrace();
    }The answer is:
    is input shut down: false is output shut down? false is bound? true is closed? false is connected? true
    server: -1Shouldn't I get something even a little bit more significant then just NO answer? sigh
    If I were to explicitly load the keystore will that get me anywhere? I am out of ideas. Anything to point somewhere would be great.
    Thank you very much,
    Iulia S.

  • Reading from CEP http channel

    How we can read from a CEP subscribed http channel through a servlet?

    yes my application will be hosted by IBM in certain environment...and the URL i am going to call through AJAX is in another domain..
    thing is...sometime i'll get the page but not the js and css for the external domain URL....
    where as i received an input from my archietect that if i make HTTP Socket connection with that URL and specify the allotted port number as well...then we are making the call from a valid connection channel...and that will make the content come back to me....with js and css...
    not sure still how it will differ from direct URL call.
    is that what you are lookign for?

  • 9.1.1 sync problems: "The disk could not be read from or written to."

    Using OSX 10.6.3 and upgraded to iTunes 9.1.1. Once I did, I keep getting the following error message: "Attempting to copy to the disk [my ipod] failed. The disk could not be read from or written to." This is followed by another error message: "iTunes could not copy {name of file} to the iPod {iPod name} because the file could not be read or written."
    I tried deleting the files mentioned in the error message, but then the message returns with the name of a different file. At this rate, I'll be deleting all my files!
    I tried checking everything on the Knowledge Base article: http://support.apple.com/kb/HT1207
    I tried restoring my iPod (twice), but it didn't help.
    All my software is up to date. I haven't added any new software since I upgraded iTunes.
    NOW...when I try to sync my iPhone, I get the same error message.
    What's going on, and can anyone help?
    This is very annoying since I can't sync my iPhone which I need or my iPod which I would like.

    ArizonaDAK wrote:
    "iTunes could not copy {name of file} to the iPod {iPod name} because the file could not be read or written."
    check if you have read & write permissions for your iTunes music folder. in finder, right-click on it and +get info+. unlock the little padlock (you may have to enter your admin password) and change the permission settings. next, click on the little gear-shaped icon and +apply to enclosed items+ like so
    you may also give everyone read & write access. if this doesn't help, try the same on your iTunes folder (not just the iTunes music folder).
    if that make no difference, try reinstalling iTunes. click here and follow the instructions. next, download a fresh copy from here: http://www.apple.com/itunes/download/.
    you might also try to _*remove and reinstall the Apple Mobile Device Service*_
    JGG
    edited by the Jolly Green Giant (where Green stands for environmentally friendly)

  • Error when syncing iPod: The disk could not be read from or written to!!

    I have an iPod mini which worked fine on my Windows XP.
    Recently got Windows Vista and I downloaded iTunes and my put my music in the library.
    When I plugged my iPod into the Vista, it said it was syncing all the songs to my iPod.
    After about 3 hours, whilst syncing the last song a notice came up saying, 'Attempting to copy to the disk failed. The disk could not be read from or written to.'
    I restored my iPod and reinstalled iTunes but the same thing happend.
    I decided to plug my iPod back into the Windows XP, where I've had no problems. When I did this and started snycing all the songs, I got the notice come up again.
    'Attempting to copy to the disk failed. The disk could not be read from or written to.'
    I haven't been able to use my iPod now for about 5 weeks because I cannot solve the problem so any help will be much appreciated!
    Thanks

    You have posted in the Mac forum for problems & questions usting the iTunes store. You will probably find more help in the following forum.
    http://discussions.apple.com/forum.jspa?forumID=800

  • Please help! iPod won't sync: "Disk could not be read from or written to."

    I am at the end of my rope with the endless problems I've been having with iTunes and my iPod ever since the iTunes update which included Gapless Playback (a feature which now invariably crashes my entire computer unless I disable it quickly enough). My latest problem has now made my iPod completely useless because I cannot sync it with my music library. Every time it tries to update the songs, it either crashes or I get the error message "Disk could not be read from or written to." I have tried restoring my iPod, which seemed to work, except that after the restore function seemingly completed I still have the flashing Do Not Disconnect screen on my iPod (after about 30 minutes). I already tried synching my iPod while this was going on and I got the same disk error message. Please, please, can anyone tell me what on earth is going on? I've NEVER had problems like this and all of a sudden it seems like everything about iTunes is a complete disaster.

    I had the same problem after I moved my library from my PC to my new iMac. It would not sync properly. After a day of thinking about it, researching it, and trying things like starring at the screen to see what song it failed on as it ran the auto sync (a suggestion posted on this site), a light bulb went off. Switch it to manual! If you manually manage the songs that sync it is easy to discover what songs fail. When auto sync is managing it, it jumps all over the place when synchronizing, but if you manually grab say 500 +/- songs at a time, it goes in alphabetical order, and you can see where it fails. It will be the track(s) immediately following the the last track that made it on the iPod. The songs that were corrupted for me played fine in iTunes, but would not transfer to the iPod, and they worked when I was syncing with my PC. Hmmm? I hope this helps.

  • Error reading from file glibc-2.5-24.i686.rpm RHEL 5 Setup stuck at 80%

    Hi, I am installing Oracle 10g on RHEL 5 (Red Hat Enterprise Linux 5) machine I am facing two problems
    1) while installing the rpm packages the following package gave an error
    Error reading from file glibc-2.5-24.i686.rpm
    2) I still gave a try to runInstaller command the installer opened but was stuck at 80%
    I have 3 GB ram and 320GB hard drive I am not sure what to put in the swap memory and other settings i blindly followed instructions given here
    http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnRHEL5.php
    What could be the problem where do I find the error log if its created
    Please help me
    Thanks
    Edited by: 891355 on Nov 6, 2011 12:06 PM

    I found the installActions file in the installer folder and I think this could be the problem
    INFO: The 'shiphomeproperties.xml' file is missing from shiphome location '/home/oracle/Desktop/database/install/../stage/products.xml.' Add this file to the 'Disk1/stage' directory of the shiphome.
    though I am attaching the log file for more details do you think the installer is corrupt :(
    InstallActions log file ==> http://www.mediafire.com/?nh7mx7bxqht9ovu
    Edited by: 891355 on Nov 6, 2011 1:35 PM

  • Reading from other object

    Hi Guys,
    I dont know whether am following the correct way , I have a scenerio where I have to show in the report Blocking reasons . I have a field from DS Payment Block Key which is 0PMNT_BLOCK in BI. I have 7 Blocking reasons in one table called BSEG and I have enhanced my 0FI_AP_4 DS to include this 7 fields and mapped to 7 BI Objects 0BLCKRSN_PR for price 0BLCKRSN_QL for quality....Now bringing these fileds from BSEG effecting performance as each time the exit is calling. I do have a Text data source (0PMNT_BLOCK_TEXT) which is having same data as I need...So in order to get this Blocking reasons in to my report without enahcing from BSEG table Iam trying to read it from master data . but its not allowing me to do that....When I say read from master data for one of the info object 0BLCKRSN_PR and press F4 its showing no info object available for reading of master data....Can any one tell me why its showing this error...I do have a Master data object 0PMNT_BLOCK which is having the values A B D H M P , so I want to read the above object 0BLCKRSN_PR from this Object ...as P is for Price and so on....
    Do I need to take the seven info objects as attributes of 0PMNT_BLOCK ?
    If so , I didnt find a DS for attributes in ECC , I have only Text DS 0PMNT_BLOCK_TEXT....
    Please advice me what I need to do for this...Also please shoot me a reply If you ahve any more questions....

    the join produces more rows then the sum of it's parts (e.g. 154). For example:
    select owner, name
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    633 rows selected.
    select owner, type
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    926 rows selected.
    select ds1.owner, ds1.name, ds2.type
    from all_source ds1 inner join all_source ds2 on (ds1.owner = ds2.owner and ds1.name = ds2.name and ds1.type = ds2.type)
    where upper(ds1.text) like '%BINARY_INTEGER%'
    and upper(ds2.text) like '%PLS_INTEGER%'
    5710 rows selected.
    select owner, count(name) as name_cnt
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    group by owner
    OWNER NAME_CNT
    SYS 577
    WWW 56
    2 rows selected.
    select owner, count(type)
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    group by owner
    OWNER COUNT(TYPE)
    SYS 909
    WWW 17
    2 rows selected.
    this could be a solution then:
    select ds1.owner, ds1.name_cnt, ds2.type_cnt
    from (select owner, count(name) as name_cnt
    from all_source
    where upper(text) like '%BINARY_INTEGER%'
    group by owner) ds1 inner join (select owner, count(type) as type_cnt
    from all_source
    where upper(text) like '%PLS_INTEGER%'
    group by owner) ds2 on (ds1.owner = ds2.owner)
    OWNER NAME_CNT TYPE_CNT
    SYS 577 909
    WWW 56 17
    2 rows selected.

  • Disk cannot be read from or written to

    When transferring files from a Windows XP Pro system to an iPod Nano, I will get an error the gist of which is "Disk cannot be read from or written to". The error is repeatable and only occurs on certain files. The nano is connected via a USB 1.1 port through a hub. (The machine has no USB 2.0 ports.) You can load other files with no problem both before and after the error appears; but not on the file which caused the problem.
    The problem smells like a firmware bug.
    (Note: I tried all of the standard resets and other workarounds - updater, etc. None of that works.)
    iPod Nano   Windows XP Pro  

    I have been getting the same error as well. The only thing I can figure out is to restore your ipod with an older version of the updater. I fortunately had an older version on my laptop, restored it to factory default, put it back on my pc where I originally had it, opened up itunes 5.0.1 (it wanted to update it to the newer version I had on my pc but I told it no) and I have been able to save songs. I tried the advice of others to reformat my ipod with the computer management and that didn't work either. I uninstalled, reinstalled, uninstalled, reinstalled, yada yada which did nothing. The only thing I have been successful with is using an older version of the updater. I can't figure out why the newer version won't work but every time I update, I get errors like you are having. I can save files to the ipod as well as songs with the older version. I can drag and drop files to the ipod using my computer as well. Can't do that when I update to a newer version of the ipod updater. Hope this helps and if anyone has any other insight into my problem, it would be greatly appreciated.

  • Reading from a text file into a 2D array

    How do you read from a text file and put it into a 2D array? Or if someone could guide me to where I can find the information?

    This tutorial shows how to read a file:
    http://java.sun.com/docs/books/tutorial/essential/io/scanfor.html
    This tutorial shows how to create arrays with multiple dimensions:
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

  • Read from text file vi won't read file...

    I am very new to LV programming so I hope you forgive any stupid mistakes I am making.   I am using Ver. 8.2 on an XP machine.
    I have a small program that stores small data sets in text files and can update them individually or read and update them all sequentially, sending the data out a USB device.   Currently I am just using two data sets, each in their own small text file.  The delimiter is two commas ",,".
    The program works fine as written when run in the regular programming environment.   I noticed, however, as soon as I built it into a project that the one function where it would read each file sequentially to update both files the read from text file vi would return an empty data set, resulting in blank values being written back into the file.   I read and rewrite the values back to the text file to place the one updated field (price) in it'sproper place.  Each small text file is identified and named with a 4 digit number "ID".   I built it twce, and get the same result.  I also built it into an installer and unfortunately the bug travelled into the installation as well.
    Here is the overall program code in question:
    Here is the reading and parsing subvi:
    If you have any idea at all what could cause this I would really appreciate it!
    Solved!
    Go to Solution.

    Hi Kiauma,
    Dennis beat me to it, but here goes my two cents:
    First of all, it's great to see that you're using error handling - that should make troubleshooting a lot easier.  By any chance, have you observed error 7 when you try to read your files and get an empty data set?  (You've probably seen that error before - it means the file wasn't found)
    If you're seeing that error, the issue probably has something to do with this:
    Relative paths differ in an executable.  This knowledge base document sums it up pretty well. To make matters more confusing, if you ever upgrade to LabVIEW 2009 the whole scheme changes.  Also, because an installer contains the executable, building the installer will always yield the same results.
    Lastly, instead of parsing each set of commas using the "match pattern" function, there's a function called "spreadsheet string to array" (also on the string palette) that does exactly what you're doing, except with one function:
    I hope this is helpful...
    Jim

Maybe you are looking for

  • IPhoto won't open! How can I get it to open?

    (Hey, I just checked in after not doing so for many months........ and I like this new letter template!!) I have Snow Leopard 10.6.8. (It says 10.6.5 below, but that has not yet been updated.) The message window says that I have iPhoto 9.1.5 installe

  • Calendar Meeting Invite from Outlook 2010 to iCal

    Hello, I am very VERY new to Macs and to be honest Calendar invites in general (Came from a Lotus Domino environment). I have come across an oddity that I am almost sure is related to the content of the .ICS file generated by Outlook and then sent to

  • How to start career with oracle

    Hi All, I am not for sure if here is right place to post my question. Well,I want to know what skills people should have if he want to take job as ORACLE DBA or ORACLE application developer. I have seen a lot job post on Dice.com website.They look li

  • Multiple Agreement for Single Project

    Hi All, In our Implementation client generally gets multiple agreements for a single project. How to specify the Agreement Reference when we are creating an Event for billing? By the way have set up the funding option at the Project Level. Thanks in

  • Re: Qosmio X300 - Webcam is not working

    Hi there, First of all, my apologies if this issue has already been discussed and solved in another thread - I tried searching this forum for "webcam" but didn't get any results. Right, my laptop model is: Qosmio X300-11S PQX32E-00M00LEN and am curre