• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I'm new to sevlets help

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You I think that helps me out. I didn't know which came first the JSP or the servlet.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple Command, again the courtesy of Ben Souther.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps this article on web app structure (and its history) might prove helpful.
 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the information.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to set the path to make my tomcat run on my system..
please help me out
 
Donna Bachner
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic