aspose file tools*
The moose likes Servlets and the fly likes I'm new to sevlets help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "I Watch "I New topic
Author

I'm new to sevlets help

Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
I have to write a servlet that calculates taxes. I'm confused on if I need an index page and if I use an html/or JSP page to get the information from the user. Does the servlet then write the results into an HTML page? Or do I use the sevlet to write the HTML for the information then get the answers and send it back out as an HTML page. I'm very confused.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Go this way.

- write a jsp page to get the information from user in a html form
- send the request to your servlet upon submit click
- call some handler, could be a plain java class, to extract all the data and fill your TO (Transfer Object)
- pass your transfer object to your business logic object that would calculate the tax for you
- after all these done, send the result jsp page to browser

For simple example please refer to The courtesy of Ben Souther
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
Thank You I think that helps me out. I didn't know which came first the JSP or the servlet.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Simple Command, again the courtesy of Ben Souther.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Donna Bachner:
Thank You I think that helps me out. I didn't know which came first the JSP or the servlet.


Actually JSP and Servlets both serves different purpose. But can be used in place of eachother. But we know the right tool to knock the work down. JSP is used for presentation stuff, whereas Servlet is used as a controller. Thus, I have given you the link to command pattern for clear understanding.

It is not the matter of choose either one. We can utitlize both technologies to get our work done in a nice way and to come up with a better cleaner design.
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
Now I want to make sure I have this right. I take my JSP page where i click submit send it to the servlet page where it goes to the java class file. Right.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60049
    
  65

Perhaps this article on web app structure (and its history) might prove helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
Thanks for the information.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Donna Bachner:
Now I want to make sure I have this right. I take my JSP page where i click submit send it to the servlet page where it goes to the java class file. Right.


Right.
Srirambhatla dileep kumar
Greenhorn

Joined: Jan 07, 2006
Posts: 22
how to set the path to make my tomcat run on my system..
please help me out
Donna Bachner
Ranch Hand

Joined: Oct 08, 2004
Posts: 109
my servlet file is not in the same folder as the JSP file. The one can't find the other. I'm using netbeans 5.5 and I get the JSP file just fine. When I click submit on the JSP I get a can't find this page. I tried to put the entire path from C:/ ... and I tried just the file name. any ideas?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Donna,
I think you'll find that this whole project will move more quickly, and be more satisfying, if you step back from it a bit and take some time to learn about the fundamentals of a servlet app.

There are lots of good tutorials out there.
Tomcat has one right on their site:
http://tomcat.apache.org/tomcat-5.5-doc/appdev/index.html

I also think that people learning servlets are better off if they don't rely on an IDE to organize their first few apps.
If you code, compile, and deploy your first "Hello, World" app with javac and a standalone instance of Tomcat, you will understand the file structure of a webapp and have a much better time debugging them when things go wrong later. Once you feel comfortable working with these small apps, then see if an IDE can speed things up for you.

-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Srirambhatla dileep kumar:
how to set the path to make my tomcat run on my system..
please help me out


You had better start new thread for your question.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I'm new to sevlets help
 
Similar Threads
Question on JspWriter&PrintWriter
Get internal HTML link from HttpServletRequest object?
Question about posting..... urgent....
Can I send servlet response to javascript?
help---please