What is needed to start a web-based project?

Discussion in 'Java' started by Roger Helliwell, Feb 3, 2004.

  1. Hello Java Experts,

    I've been using Java to write stand alone apps for a number of months.
    I have now been asked to create a web-based solution, but having no
    web-programming experience, the task seems daunting. I bought myself a
    book on JSP and thought that would be the ticket -- but, umm, no.

    So were does one "start"? All the online tutorials I've read so far,
    explain the details but not the general idea. Can I still use eclipse
    to compile Jsp files, or will I need something else?

    What do I need to write an app that runs on a web-server, takes a text
    file that a web-user has submitted, processes it (this I can do), and
    sends the results back to the client? I do have HTML and some
    javascripting knowledge, but just stuck on how the pieces go together.
    (What should run on the server, what runs on the client etc.)

    Thanks,
    Roger
     
    Roger Helliwell, Feb 3, 2004
    #1
    1. Advertising

  2. "Roger Helliwell" ...
    > Hello Java Experts,


    Given that salutation, I should probably
    not respond. I have only just dipped my
    toe into J2EE. (and am no expert on the
    J2SE!)

    But (shrugs) what the hey.

    > I've been using Java to write stand alone apps for a number of months.
    > I have now been asked to create a web-based solution, but having no
    > web-programming experience, the task seems daunting. I bought myself a
    > book on JSP and thought that would be the ticket -- but, umm, no.
    >
    > So were does one "start"? All the online tutorials I've read so far,
    > explain the details but not the general idea. Can I still use eclipse
    > to compile Jsp files, or will I need something else?


    Install Apache/Tomcat on your system,
    JSP's will be compiled the first time they
    are called (you open the .jsp file from
    'localhost')

    > What do I need to write an app that runs on a web-server, takes a text
    > file that a web-user has submitted, processes it (this I can do), and
    > sends the results back to the client?


    Heck, it sounds like you are almost there.

    Is it _only_ the 'data back to client' you are
    having trouble with? Or are you also trying
    to figure how to convert the earlier bits
    to use .jsp as well?

    >..I do have HTML and some
    > javascripting knowledge, but just stuck on how the pieces go together.
    > (What should run on the server, what runs on the client etc.)


    You can write a lot of webapps where the
    only thing the client sees is html. This is
    one of the things that got me into server side
    stuff as I want to be able to cater to anyone
    with a browser that understands html, which
    is a much wider user base than UA's with
    'a current Java' installed..

    HTH

    --
    Andrew Thompson
    * http://www.PhySci.org/ Open-source software suite
    * http://www.PhySci.org/codes/ Web & IT Help
    * http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Feb 3, 2004
    #2
    1. Advertising

  3. On Tue, 03 Feb 2004 05:49:24 GMT in comp.lang.java.programmer, "Andrew
    Thompson" <> wrote:

    >> What do I need to write an app that runs on a web-server, takes a text
    >> file that a web-user has submitted, processes it (this I can do), and
    >> sends the results back to the client?

    >
    >Heck, it sounds like you are almost there.
    >
    >Is it _only_ the 'data back to client' you are
    >having trouble with? Or are you also trying
    >to figure how to convert the earlier bits
    >to use .jsp as well?
    >


    Say a web-user is presented with a form to enter a file name with a
    "Submit" button (ie. imagine attaching a file to an e-mail). How would
    the server accept the file for processing? This couldn't be javascript
    since I always thought js didn't have client-side file functionality.

    Roger
     
    Roger Helliwell, Feb 3, 2004
    #3
  4. Roger Helliwell wrote:
    > On Tue, 03 Feb 2004 05:49:24 GMT in comp.lang.java.programmer, "Andrew
    > Thompson" <> wrote:
    >
    >>> What do I need to write an app that runs on a web-server, takes a
    >>> text file that a web-user has submitted, processes it (this I can
    >>> do), and sends the results back to the client?

    >>
    >> Heck, it sounds like you are almost there.

    ...
    > Say a web-user is presented with a form to enter a file name with a
    > "Submit" button (ie. imagine attaching a file to an e-mail). How would
    > the server accept the file for processing? This couldn't be javascript
    > since I always thought js didn't have client-side file functionality.


    No, I do not think this can be done in JS,
    certainly not client-side JS.

    As far as file _uploads_ go, I would have
    to cede to others, it is something I have
    been meaning to look into.

    But (scratches head) what you are asking now
    does not gel with your earlier comment. I
    understood from your initial statement..

    <this I can do>
    write an app
    take a text file
    process it
    </this I can do>

    Did I misunderstand you?

    --
    Andrew Thompson
    * http://www.PhySci.org/ Open-source software suite
    * http://www.PhySci.org/codes/ Web & IT Help
    * http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Feb 3, 2004
    #4
  5. Roger Helliwell

    KC Wong Guest

    > Say a web-user is presented with a form to enter a file name with a
    > "Submit" button (ie. imagine attaching a file to an e-mail). How would
    > the server accept the file for processing? This couldn't be javascript
    > since I always thought js didn't have client-side file functionality.


    Uploading file... that's not the first step if you're new to webapps.

    Do you understand how to do this?
    User fills data in a HTML form retrieved from server, submit it, then server
    receives the response, validates it (prompts user to re-enter on error) and
    stores the data in a file on the server or in database.

    If yes:
    Take a look at Oreilly's servlet package
    (http://www.servlets.com/cos/index.html). It has a multipart parser which
    makes uploading files easy as pie. You can't use it for commercial projects
    though.

    If not:
    Then you need to start from the basics first. I'll post more if you need
    them - just ask!


    HTH,

    KC
     
    KC Wong, Feb 3, 2004
    #5
  6. Roger Helliwell

    Ryan Stewart Guest

    "Andrew Thompson" <> wrote in message
    news:ftJTb.40698$...
    *snip*
    > As far as file _uploads_ go, I would have
    > to cede to others, it is something I have
    > been meaning to look into.

    *more snip*

    See http://www.servlets.com/cos/index.html as suggested by KC Wong.
    Specifically pay attention to the MultipartRequest. Using that with a <input
    type="file" ... > tag, you can write a quick and dirty file upload JSP in
    about a dozen lines.
     
    Ryan Stewart, Feb 3, 2004
    #6
  7. On Tue, 3 Feb 2004 17:05:00 +0800 in comp.lang.java.programmer, "KC
    Wong" <> wrote:

    >Uploading file... that's not the first step if you're new to webapps.
    >
    >Do you understand how to do this?
    >User fills data in a HTML form retrieved from server, submit it, then server
    >receives the response, validates it (prompts user to re-enter on error) and
    >stores the data in a file on the server or in database.
    >
    >If yes:
    >Take a look at Oreilly's servlet package
    >(http://www.servlets.com/cos/index.html). It has a multipart parser which
    >makes uploading files easy as pie. You can't use it for commercial projects
    >though.
    >
    >If not:
    >Then you need to start from the basics first. I'll post more if you need
    >them - just ask!


    I'm afraid it's the latter. I'm in a situation like you've mentioned--
    I've got a server-side app that simply processes text files, and it's
    just waiting for a web-user to press a "Submit" button to send the
    file.

    Thanks for the link, it's one I haven't discovered yet, and looks
    promising.

    Roger
     
    Roger Helliwell, Feb 4, 2004
    #7
  8. Roger Helliwell

    KC Wong Guest

    Hello Roger,

    > >Do you understand how to do this?
    > >User fills data in a HTML form retrieved from server, submit it, then

    server
    > >receives the response, validates it (prompts user to re-enter on error)

    and
    > >stores the data in a file on the server or in database.
    > >
    > >If not:
    > >Then you need to start from the basics first. I'll post more if you need
    > >them - just ask!

    >
    > I'm afraid it's the latter. I'm in a situation like you've mentioned--
    > I've got a server-side app that simply processes text files, and it's
    > just waiting for a web-user to press a "Submit" button to send the
    > file.


    Test and play around with this example...

    test.jsp

    <%
    String username = "";
    String hiddenValue = "abc";
    boolean posted = false;

    if ("post".equalsIgnoreCase(request.getMethod())) {
    posted = true;
    username = String.valueOf(request.getParameter("username"));
    hiddenValue = String.valueOf(request.getParameter("hiddenValue"));
    %>
    You submitted these data:
    <%
    }
    %><html>
    <body>
    <form name="testForm" action="test.jsp" method="post">
    Username: <input type="text" name="username" value="<%= username %>"><br/>
    <%= (posted)? "Hidden Value: " : "" %><input type="<%= (posted)? "text" :
    "hidden" %>" name="hiddenValue" value="<%= hiddenValue %>">
    <%
    if (!posted) {
    %>
    <input type="submit" value="Submit Form"/>
    <%
    }
    %>
    </form>
    </body>
    </html>

    Put this JSP in your webapp directory, open it with browser and see what
    happens.
    It is a simple example of:
    - Dynamically generate form from server
    - Submit data from client
    - Process data on server side
    - Generate report to client


    This is an file-upload example using the Oreilly servlet package.

    <%@page contentType="text/html; charset=UTF-8"
    %><%@page import="com.oreilly.servlet.*, com.oreilly.servlet.multipart.*"
    %><%@page import="java.io.*, java.util.*"
    %><%
    try {
    if ("POST".equalsIgnoreCase(request.getMethod())) {
    // Handle upload
    MultipartRequest mr = new MultipartRequest();
    mr.startUpload(request, "C:\\", "Test_");

    Enumeration e = mr.getFileNames();
    while (e.hasMoreElements()) {
    //
    String id = String.valueOf(e.nextElement());
    File f = mr.getFile(id);
    %>
    File ID : <%= id %><br/>
    Filename : <%= mr.getRealName(id) %><br/>
    MIME Type: <%= mr.getContentType(id) %><br/>
    <%
    }
    }
    } catch (Exception ex) {
    %>
    Error Message: <%= ex.getMessage() %><br/>
    <%
    }
    %><html>
    <head>
    </head>
    <body>
    <form enctype="multipart/form-data" action="test.jsp" method="POST">
    Upload File: <input type="file" name="myFile1"><br/>
    <input type="submit" value="Upload">
    </form>
    </body>
    </html>

    The trigger is the line: mr.startUpload(...).
    The file will be uploaded from the client to your server's C:\.

    Make sure you read the API documentation of the Oreilly servlet package!


    HTH,

    KC
     
    KC Wong, Feb 4, 2004
    #8
  9. Roger Helliwell

    JayDay Guest

    Roger Helliwell <> schreef op Tue, 03 Feb 2004
    05:28:24 GMT:
    > I've been using Java to write stand alone apps for a number of months.
    > I have now been asked to create a web-based solution, but having no
    > web-programming experience, the task seems daunting. I bought myself a
    > book on JSP and thought that would be the ticket -- but, umm, no.


    Hi,

    I already installed TomCat for some other projects, but I only used
    servlets. Then it took me 1 day to learn JSP and create a simple interface
    to my java program. I'm not a genius, so it cant be very difficult.

    sptest
     
    JayDay, Feb 28, 2004
    #9
    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. Claude seraphin
    Replies:
    12
    Views:
    2,539
    samundersingh1983
    Feb 15, 2014
  2. Ken Stealth
    Replies:
    2
    Views:
    4,373
    =?Utf-8?B?amRneChDb2xvbWJpYSk=?=
    Jan 31, 2004
  3. Jon Davis
    Replies:
    0
    Views:
    891
    Jon Davis
    Nov 14, 2006
  4. nancyflorida
    Replies:
    0
    Views:
    368
    nancyflorida
    Nov 12, 2007
  5. nancyflorida
    Replies:
    0
    Views:
    355
    nancyflorida
    Nov 12, 2007
Loading...

Share This Page