Home Servlets say hello in spanish
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

say hello in spanish

Advertisement
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.io.*;
import java.text.*;
import java.util.*;

public class SayHelloToSpain extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
res.setHeader("Content-Language", "es");
Locale locale = new Locale("es", "");
DateFormat df = DateFormat.getDateTimeInstance
(DateFormat.LONG,DateFormat.LONG,locale);
df.setTimeZone(TimeZone.getDefault());
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.

Advertisement

Liked it!  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.

Posted on: July 19, 2007

Ask Questions?    Discuss: say hello in spanish   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
DMCA.com