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.
- 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
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.
Joined: Oct 08, 2004
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.
how to set the path to make my tomcat run on my system.. please help me out
Joined: Oct 08, 2004
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?
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.