Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > What is needed to start a web-based project?

Reply
Thread Tools

What is needed to start a web-based project?

 
 
Roger Helliwell
Guest
Posts: n/a
 
      02-03-2004
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

 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      02-03-2004
"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


 
Reply With Quote
 
 
 
 
Roger Helliwell
Guest
Posts: n/a
 
      02-03-2004
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

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      02-03-2004
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


 
Reply With Quote
 
KC Wong
Guest
Posts: n/a
 
      02-03-2004
> 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


 
Reply With Quote
 
Ryan Stewart
Guest
Posts: n/a
 
      02-03-2004
"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.


 
Reply With Quote
 
Roger Helliwell
Guest
Posts: n/a
 
      02-04-2004
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
 
Reply With Quote
 
KC Wong
Guest
Posts: n/a
 
      02-04-2004
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


 
Reply With Quote
 
JayDay
Guest
Posts: n/a
 
      02-28-2004

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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set Start URL with project Start Page (Visual Studio) Jon Davis ASP .Net 0 11-14-2006 08:23 PM
Start Web services as Windows Services start Anup ASP .Net 1 05-09-2006 11:44 AM
My mouse Hangs when I start my computer and then start Firefox booddhhoo Computer Support 3 03-12-2006 05:38 PM
PROCESS.START Help - Need to start app that listens on a port Lucas Tam ASP .Net 0 06-17-2005 02:09 PM
Specify start and length, beside start and end, in slices Noam Raphael Python 17 05-26-2004 09:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57