Share on Google+Share on Google+

say hello in spanish

In this program we are going to display "hello" in spanish along with the date.

say hello in spanish


In this program we are going to display "hello" in spanish along with the date.

To make this program we need to make a class SayHelloToSpain. To main logic of the program will be written inside the doGet() method of the servlet. To print "hello" in servlet setHeader() method of the response object should be "es". Here "es" means the content language is spanish.

The code of the program is given below:

import javax.servlet.*;
import javax.servlet.http.*;
import java.text.*;
import java.util.*;

public class SayHelloToSpain extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();
res.setHeader("Content-Language", "es");
Locale locale = new Locale("es", "");
DateFormat df = DateFormat.getDateTimeInstance
out.println("Hello spain will be written in this way");
out.println("En Espaņol:");
out.println("\u00a1Hola Mundo!");
out.println(df.format(new Date()));

The output of the program is given below:


Download this example.


Posted on: July 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: say hello in spanish   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image