Home Servlets say hello in spanish



say hello in spanish
Posted on: July 19, 2007 at 12:00 AM
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.

Related Tags for say hello in spanish:
cideclassobjectlanguageservletheadermakemethodprintgetlogiccontentintthisidresponselogaisetprogramtoramspanldlansheilmainitulinasmheadntsidsidespanishososletjadclesagememeanobjpropandostheadspeeespkishellollnispaineasarvwrittenttssrithshohellojepronogro


More Tutorials from this section

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

Post your Comment


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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.