VB icon

Hello World in Servlet

Email
Submitted on: 9/13/2015 6:24:43 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: Java (JDK 1.1), Java (JDK 1.2), Java (JDK 1.3), Java (JDK 1.4), Java (JDK 1.5)
Views: 2510
author picture
 
     I just started how to learn how to program a Java Servlet so the basic program that I wrote is the famous hello world program with a simple math functions in Java like square root and cube root. In this program I am using Eclipse as my text editor and Apache Tomcat 8.0 as my web server. This program is very simple yet is show you how to write a simple Java servlet that is the fundamentals of any web applications written in Java. If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Hello World in Servlet
// Description:I just started how to learn how to program a Java Servlet so the basic program that I wrote is the famous hello world program with a simple math functions in Java like square root and cube root. In this program I am using Eclipse as my text editor and Apache Tomcat 8.0 as my web server. This program is very simple yet is show you how to write a simple Java servlet that is the fundamentals of any web applications written in Java.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.
// By: Jake R. Pomperada
//**************************************

package company.helloworld.servlets;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * Servlet implementation class HelloWorld
 */
@WebServlet("/HelloWorld")
public class HelloWorld extends HttpServlet {
 private static final long serialVersionUID = 1L;
/**
 * @see HttpServlet#HttpServlet()
 */
public HelloWorld() {
super();
// TODO Auto-generated constructor stub
}
 /**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 PrintWriter out = response.getWriter();
 double sqrtvalue = Math.sqrt(144.0);
 double cuberoot = Math.cbrt(8.0);
 
 out.println("<html><body> <font color='green'> <h1 align='center'>Hello World Servlet </h1> "
+ "The square root of 144 is " + sqrtvalue
+ "<br>The cube root of 8 is " + cuberoot + "</font> </body></html>");
 }
 /**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 // TODO Auto-generated method stub
 }
}


Other 53 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.