<jsp:useBean File Read Write, File Locations and GoDaddy.com

Discussion in 'Java' started by LB, May 27, 2008.

  1. LB

    LB Guest

    I'm trying to hone my Java and Java EE skills. I'm helping someone on
    their website, using a GoDaddy Linux shared hosting. I've been able
    to accomplish a lot including a feedback --> email application. What
    I'm trying to do now is keep a running tally on feedback in a simple
    Comma Seperated Variable (CSV) text file on the web site.

    All .jsp code is done thru <jsp:useBean ... and setters and getters.
    I'm building the web site applications using NetBeans IDE. I verify
    things are working on my local drive before I go to GoDaddy. GoDaddy
    is very cost effective but it has some minor drawbacks.
    1) You are on a shared server. You get no control on the server. You
    can not look at the server logs.
    2) Servlets, once executed, stay that way for 24 hours. If you
    upgrade your java app, upload it, it won't become functional until
    after 1AM Mountain time. Obviously the easiest way around that is to
    constantly increment your class package name (or do it right the first
    time on your local server, ha!)
    3) Web/File organization is not intuitive. (hence my current
    problem.) The only guidance from GoDaddy is that in order to read/
    write files, you must be in a /tmp directory.

    What I'm struggling with is the naming convention for file
    directories.

    GoDaddy Tree Structure:
    html
    html/gci
    html/Flash
    html/images
    html/php_uploads
    html/stats
    html/WEB-INF
    html/WEB-INF/classes
    html/WEB-INF/lib

    First trick was where to place my compiled class files. In this case,
    I added javapackage to the source package within my NetBeans project.
    That package contains my custom.java class. When mapped to the
    GoDaddy interface, the compiled custom.class ends up going to:

    (godaddy) html/WEB-INF/classes/javapackage/custom.class

    (solution took a long time to figure out.. offered here for others who
    might have same problem in future.)

    Here is my current dilemma. I want to append a text (CSV) file. My
    program works okay on my local drive with NetBeans, kinda sorta.

    Java Code snippet:

    PrintWriter userout = new PrintWriter(new FileWriter(new File("/
    VisitLog.csv"),true)); // mode true = append
    userout.println(getCSVText()); // Simple String data
    userout.close();

    This works okay, but /VisitLog.csv maps to c:/VisitLog.csv on my local
    drive. I can see that the file is getting appended correctly, but
    that location scheme won't work on GoDaddy.com

    Problem #1: How can I add a "tmp" directory within NetBeans project
    so VisitLog.csv is contained directly within the project? (I've tried
    adding a subdirectory "tmp" and I can see it, but I don't know how to
    access the file from java. I've tried numerous variants...) How do I
    define my PrintWriter userout (see above) with this location?

    Problem #2: Where do I place the file within GoDaddy to get my
    PrintWriter to access it?
    (I understand that I have to change permissions, etc..) Obviously it
    be cool if I could have common java code between NetBeans local and
    GoDaddy.

    Anybody been here before? Anybody have really good understanding of
    naming conventions and directory trees within a web server?

    Many thanks in advance,
    LB
    Detroit, MI
     
    LB, May 27, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P.Hill
    Replies:
    4
    Views:
    9,386
    Chris Riesbeck
    Feb 5, 2004
  2. Sean Aitken
    Replies:
    3
    Views:
    11,143
    Alex Hunsley
    Oct 21, 2004
  3. Anan H. Samiti
    Replies:
    1
    Views:
    7,695
    kaeli
    Sep 27, 2004
  4. Ulf Meinhardt
    Replies:
    1
    Views:
    4,642
    Tor Iver Wilhelmsen
    Oct 14, 2004
  5. zalek
    Replies:
    1
    Views:
    380
Loading...

Share This Page