Java translator

Hi,
i need a translator i can use in my java application to translate from italian to german? Any idea?

I agree there is merit to the porting to Java but consider the following complexities of moving to Java in an automated fashion.
C++ provides templates, structs, multiple inheritance, operator overloading, pass by reference and explicit destruction.
Whilst Java provides none of these it does provide stronger RTTI, safe casting, a powerful encapsulation model through inner classes and a package hierarchy, dynamic class-loading and interfaces.
I expect many here can suggest even more fundamental differences so treat my list as the tip of the iceberg.
I'd seriously suggest rethinking the application and rewriting rather than trying to automate any kind of porting.
Talden

Similar Messages

  • Help with java translator...PLEASE!!!

    I am currently in the process of learning the JAVA language.
    i am having real problems tackling a question about programming a translator, can anyone help with this question?
    - Write a Java class 'German' to model the german dictionary(using only a few phrases, say 4-5). You will need to choose an appropriate representation for the constant dictionary(ignore accents etc), and to provide a method 'Translate' that, given an English phrase, returns the corresponding German phrase. You must also deal with phrases that are not available.
    I hope someone can help...
    John

    Learn a Map structure.

  • Perl to Java translation

    What is the java equivalent of the following perl code?#!/usr/bin/perl
    use strict;
    use warnings;
    use Net::FTP;
    my $file = shift;
    my $server = 'domain.com'; (edited out)
    my $username = 'username'; (edited out)
    my $password = 'password'; (edited out)
    my $remote_dir = 'domain.com'; (edited out)
    my $ftp = Net::FTP->new($server) or die "can't connect to $server: $@";
    $ftp->login($username, $password) or die "can't login ", $ftp->message;
    $ftp->cwd($remote_dir) or die "can't cd to $remote_dir ", $ftp->message;
    $ftp->put($file) or die "can't transfer $file", $ftp->message;
    $ftp->quit;
    exit 1;Thank you!

    http://www.google.com/search?q=FTP+Java

  • How to invoke "javac" and "java" command so that I can write my complier

    thanks

    Have a look in tools.jar under sun.tools.javac.Main is the standard javac complier.
    You can decompile this library and get a good idea of what goes into writing a compiler.
    If you want to write your own compiler you might find creating a MyLanguage to java translator will be easier to build.

  • Where can i see the java file of a container converted JSP file

    I am using weblogic11g.
    Where can i see the java file of a container converted JSP file .

    Hello.
    If you look for .class files, you will find them under $domain/servers/serverName/tmp/application/etc.
    If you look after .java translated files, nowhere if you don't have "keepgenerated" param set to true in the appc/jspc command line (may be set in a web descriptor but can't find a reference). The foo.java will be find in .\WEB-INF\classes\jspservlet.
    Edit: http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webapp/weblogic_xml.html
    Regards.
    Aurélien.
    Edited by: Aurelien DEHAY on 24 août 2009 17:12

  • Microsoft Word "Smart Quotes"

    I hope this will save other developers some time.
    This may be obvious to others, but I just spent several hours Googling and testing to determine what actually happens when a user copies text containing "Smart Quotes" from Microsoft Word into a Java JTextComponent. For those not familiar with Smart Quotes, by default, MS Word changes double-quoted strings from using the US-ASCII character for quote (0x22) into left- and right- curly quotes (UTF-16: 0x201c and 0x201d). Word also does this with serveral other characters. This plays havoc with the display and Java Strings later encoded with java.beans.XMLEncoder, unless treated carefully. Here is what I discovered (obviously, this applies to MS Windows):
    All values are in hexadecimal.
    - Word is storing the character for double quote as UTF-16 internally (201C).
    - When the character is copied to the clipboard, it is copied as UTF-8 (E2 80 9C).
    - When the clipboard is pasted into Java, Java is assuming the it was originally Windows-1252 encoded, because that is the default for the US-EN locale in Windows XP (probably also Vista, but I only tested in XP).
    - Java translates this into a-circumflex, euro-sign, o-e-ligature, the characters corresponding to E2, 80, and 9C respectively in Windows-1252 and represents it internally in UTF-16 as 00E2 20AC 0153.
    -When the String is XML-encoded using java.beans.XMLEncoder, it is written in UTF-8 as C3A2 E282AC C593, which equates to UTF-16 00E2 20AC 0153 -- the characters a-circumflex, euro-sign, o-e-ligature.
    I am not sure how to fix this, but maybe another reader does. I am experimenting with the Clipboard (java.awt.datatransfer) to see if I can programmatically find out the original character encoding (in this case, UTF-16).

    Doesn't the DataFlavor contain the character encoding? What is the content of the InputStream returned by
                InputStream is = (InputStream)contents.getTransferData(DataFlavor.getTextPlainUnicodeFlavor());
    If I use
                    DataFlavor df = DataFlavor.getTextPlainUnicodeFlavor();
                    String mimeType = df.getMimeType();
                    String encoding = mimeType.replaceAll(".*?charset=(.*?)\\s*$", "$1");
                    InputStream is = (InputStream) contents.getTransferData(df);
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    byte[] buffer = new byte[1024];
                    for (int count = 0; (count = is.read(buffer)) != -1;)
                        baos.write(buffer, 0, count);
                    baos.close();
                    result = baos.toString(encoding);to transfer
    Hello "World"
    which Word changes the quotes to the smart 'smart quotes' version I get as a result
    Hello “World”
    which is what I expect.
    Am I missing something?
    Edited by: sabre150 on Sep 4, 2009 1:27 PM

  • Special character storage

    Berkeley DB XML V2.3.10
    Hello,
    I use Berkeley DB XML iin order to store a large amount of data. This data contains some special characters like french character, quotes,...
    I insert the documents with a java batch.
    When I retreive the datas from the berkeley bd, all special characters have been translated into something unreadable:
    "HANGOOK MCDONALD' LTD" is transform into "HANGOOK MCDONALD├óÔé¼ÔäóS CO.,LTD" for example.
    I would like to know where can I change the charset of the database?
    The code I use in order to insert my document is:
    private XmlDocumentConfig docConf = XmlDocumentConfig.DEFAULT.setGenerateName(true);
    +public void putDocument(String src) {+
    +try {+
    XmlUpdateContext uc = mgr.createUpdateContext();
    XmlDocument doc = mgr.createDocument();
    doc.setContent(src);
    db.putDocument(doc, uc, docConf);
    uc.delete();
    doc.delete();
    +} catch (Exception e) {+
    log.error(e.getMessage(), e);
    +}+
    +}+
    Best regards,
    Pierre-Yves
    Edited by: user557912 on 29 août 2008 02:56

    Pierre-Yves
    This is a bug that has to do with how Java translates a String into a byte[]. It has been fixed in dbxml 2.4, but an easy way to deal with this with older versions of the database is to replace:
    doc.setContent(src);with
    doc.setContent(src.getBytes("UTF-8"));Similarly, when getting the document content you will want to do
    String src = new String(doc.getContent(), "UTF-8");Lauren Foutz

  • Wls 8.1 sp2: weblogic.jspc complains about struts-html tags

              Hi,
              I am trying to compile jsps with weblogic.jspc, which use struts' html tags. However,
              the compilation fails with the following message:
              [java] Translation of /views/viewPageBody.jsp failed: (line 3): Error in using
              tag library uri='/tags/struts-html' prefix='html': The Tag class 'org.apache.struts.taglib.html.BaseTag'
              has no setter method corresponding to TLD declared attribute 'server', (JSP 1.1
              spec, 5.4.1)
              I opened the BaseTag class from the struts jar and found the setter exists for
              the attribute 'server' of html tld. So does the property 'server'. The property
              'server' is a string and the parameter in the setter is a string. I read about
              the jspc errors in wls 8.1 about the setter parameter being of different type
              than the property. However, that is not the case here. I tried using both Sun's
              and BEA's jdk. None of them help. Btw, there is another attribute mentioned in
              the html tld, which is 'target'. The compiler doesn't complain yet about this.:(
              Also, I happened to compile other apps which have struts logic tags.
              My environment:
              OS: Win2k sp3
              WLS: 8.1 sp2
              JDK: Sun's 1.4.2 sp4 / Bea's 1.4.1 sp5 (tried both)
              Ant: 1.5.3 (I had an issue earlier with ant until I found that Bea officially
              without any mention supports only ant 1.5.3.)
              I would appreciate any help in this regard.
              Thanks,
              Abbas
              

              What version of Struts are you trying to use?
              Are you certain you're not encountering a different instance of that class in
              an unexpected location in your classpath?
              "Abbas" <[email protected]> wrote:
              >
              >Hi,
              >I am trying to compile jsps with weblogic.jspc, which use struts' html
              >tags. However,
              >the compilation fails with the following message:
              >
              >[java] Translation of /views/viewPageBody.jsp failed: (line 3): Error
              >in using
              >tag library uri='/tags/struts-html' prefix='html': The Tag class 'org.apache.struts.taglib.html.BaseTag'
              >has no setter method corresponding to TLD declared attribute 'server',
              >(JSP 1.1
              >spec, 5.4.1)
              >
              >I opened the BaseTag class from the struts jar and found the setter exists
              >for
              >the attribute 'server' of html tld. So does the property 'server'. The
              >property
              >'server' is a string and the parameter in the setter is a string. I read
              >about
              >the jspc errors in wls 8.1 about the setter parameter being of different
              >type
              >than the property. However, that is not the case here. I tried using
              >both Sun's
              >and BEA's jdk. None of them help. Btw, there is another attribute mentioned
              >in
              >the html tld, which is 'target'. The compiler doesn't complain yet about
              >this.:(
              >Also, I happened to compile other apps which have struts logic tags.
              >
              >
              >My environment:
              >OS: Win2k sp3
              >WLS: 8.1 sp2
              >JDK: Sun's 1.4.2 sp4 / Bea's 1.4.1 sp5 (tried both)
              >Ant: 1.5.3 (I had an issue earlier with ant until I found that Bea officially
              >without any mention supports only ant 1.5.3.)
              >
              >I would appreciate any help in this regard.
              >
              >Thanks,
              >
              >Abbas
              

  • Minimum packaging to deploy JAXB?

    What is the minimum set of jars I should ship to deploy XJC-generated classes?
    I'm trying to decide whether I can use JAXB, and one important factor is deployability. For my project, I can assume that the customer already has Java 1.4, but otherwise the application must be self-contained.
    I cannot ship the entire Web Services Developer Pack: that's far too large and complex for my needs, as I'm not building a web service. All I want is XML <-> Java translation using standardized APIs, and in the case of a known, fixed schema JAXB objects have better programmer convenience and memory efficiency than generic DOM trees.
    Is there an official distribution with a simple "jaxb-runtime.jar" I can use? At the moment, I'm taking individual jars out of the WSDP, trying to find the smallest set that works.
    Here's the minimum set of Jars that seem to work for running XJC generated classes.
    <fileset dir="${jwsdp}/jaxb/lib">
    <include name="jaxb-api.jar"/>
    <include name="jaxb-impl.jar"/>
    <include name="jaxb-libs.jar"/>
    </fileset>
    <fileset dir="${jwsdp}/jwsdp-shared/lib">
    <include name="jax-qname.jar"/>
    <include name="namespace.jar"/>
    <include name="relaxngDatatype.jar"/>
    <include name="xsdlib.jar"/>
    </fileset>
    Notably absent are the jars in jaxp/lib/endorsed. The large "xsdlib.jar" overlaps a lot with xercesImpl, but not enough to use it as a standalone xsd-aware jaxp parser, which I need for other reasons.
    Noteably present is a dependency on Relax NG, which I am not using.
    Unless JAXB packaging improves, I'll be using Xerces-J plus bare DOM. Tell me there's a better way?

    I think we do not have to take the files mentioned in second <fileset/> to the client. At runtime we need:
    jaxb-api.jar, jaxb-ri.jar(jaxb-impl.jar), jaxb-libs.jar, xerces.jar and generated jar for the package. It worked for me.
    Is there an official distribution with a simple
    "jaxb-runtime.jar" I can use? The JAXB system is divided into two main parts that are completely independent.
    1. Generating classes
    2. Creating objects at runtime
    Obviouly first part needs more XML specific jars, but for second part (in which client is interested) we don't need them.
    So there can't be a true "jaxb-runtime.jar".

  • Please help with cfscript error!

    When I run my app, I got this error:
    sdfst_catcherror is recording this error: Context validation
    error for tag cfscript.; The start tag must have a matching end
    tag. An explicit end tag can be provided by adding
    </cfscript>. If the body of the tag is empty you can use the
    shortcut <cfscript .../>.
    The CFML compiler was processing:
    a cfscript tag beginning on line 45, column 4.
    a cfscript tag beginning on line 45, column 4.
    When I checked my codes, all the
    <cfscript></cfscript> have the pairs. There are only 2
    pairs of <cfscript</cfscript> in this template.
    See my code structure below:
    <!--- the first <cfscript pair> --->
    <cfscript>
    function getTRS(var5)
    some codes here...
    return TRS;
    </cfscript>
    <cffunction name="FrmTxt" returntype="Struct">
    <cfargument name="EmpCodes" required="true"
    type="array">
    <cfargument name="EmpID" required="true"
    type="numeric">
    <cfquery name="GetEmpInfo>
    Select * from......
    </cfquery>
    <cfset varFrms = GetEmpInfo.EmpCodes>
    <cfset A_Key = 1>
    <cfset structFrmTxt = StructNew()>
    <!--- The second pair --->
    <cfscript>
    Some codes here....
    Need to output #TRS# returned by getTRS(var5) set above
    </cfscript>
    <cfreturn structFrmTxt>
    </cffunction>
    From other CF forum I learned that I can't put getTRS(var5)
    within the second <cfscript></cfscript> within
    <CFFUNCTION> pair
    it says "You can't put UDF within UDF or method within
    method". When I did originally, I got this error:
    Unable to complete CFML to Java translation, Error
    information unsupported statement: class
    coldfusion.compiler.ASTfunctionDefinition
    I'm stuck and can't find any resources to solve this problem
    anymore, please help!....

    When I checked my codes, all the
    <cfscript></cfscript> have the pairs.
    This error can often mean that you did not properly end a
    previous code
    block or line. So the closing </cfscript> is being
    considered part of
    that unclosed code. For me, it is often a missing semi-colon
    [;] on the
    last line I wrote, missing a closing curly bracket [}] could
    do it as well.
    Check your code, this is seldom more then missing a bit of
    syntax.

  • Advanced queueing hotel example (sqlj error)

    can anyone help me about why this error occured when i follow all the steps of installation.
    when i exec the command ->sqlj -status -ser2class HotelSystemSLJ.sqlj HotelSQLJ.sqlj *.java
    this error occured. i use oracle 9i and my translator.zip file is copied from {9i home}/sqlj/lib
    but in my classpath both of the translator.zip file is defined. one is at 9i home and the other is at oc4j home. when i defined the only oc4j home file the command returned the error that it cant find the sqlj translator so i defined both in my classpath
    D:\oracle9ias\core\J2EE_containers\j2ee\home\applications\AQEJBHotelSample\src\
    ava\oracle\otnsamples\AQEJBHotelSample\ejb>sqlj -status -ser2class HotelSystemS
    LJ.sqlj HotelSQLJ.sqlj *.java
    [Translating 15 files]
    [Reading file HotelSystemSQLJ]
    [Reading file HotelSQLJ]
    [Reading file AQHotelMessage]
    [Reading file Hotel]
    [Reading file HotelBean]
    [Reading file HotelDetails]
    [Reading file HotelHome]
    [Reading file HotelSummary]
    [Reading file HotelSystem]
    [Reading file HotelSystemBean]
    [Reading file HotelSystemHome]
    [Reading file RequestAQHandler]
    [Reading file ReservationDetails]
    [Reading file RoomType]
    [Reading file ServiceAQHandler]
    [Translating file HotelSystemSQLJ]
    [Translating file HotelSQLJ]
    [Translating file AQHotelMessage]
    [Translating file Hotel]
    [Translating file HotelBean]
    [Translating file HotelDetails]
    [Translating file HotelHome]
    [Translating file HotelSummary]
    [Translating file HotelSystem]
    [Translating file HotelSystemBean]
    [Translating file HotelSystemHome]
    [Translating file RequestAQHandler]
    [Translating file ReservationDetails]
    [Translating file RoomType]
    [Translating file ServiceAQHandler]
    [Compiling 15 Java files]
    java.io.IOException: CreateProcess: javac -J-Djavac.pipe.output=true HotelSyste
    SQLJ.java HotelSQLJ.java AQHotelMessage.java Hotel.java HotelBean.java HotelDet
    ils.java HotelHome.java HotelSummary.java HotelSystem.java HotelSystemBean.java
    HotelSystemHome.java RequestAQHandler.java ReservationDetails.java RoomType.jav
    ServiceAQHandler.java error=2
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Unknown Source)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at sqlj.tools.Sqlj.runCompilation(Sqlj.java:910)
    at sqlj.tools.Sqlj.statusMain(Sqlj.java:384)
    at sqlj.tools.Sqlj.main(Sqlj.java:140)
    Error in Java compilation: CreateProcess: javac -J-Djavac.pipe.output=true Hote
    SystemSQLJ.java HotelSQLJ.java AQHotelMessage.java Hotel.java HotelBean.java Ho
    elDetails.java HotelHome.java HotelSummary.java HotelSystem.java HotelSystemBea
    .java HotelSystemHome.java RequestAQHandler.java ReservationDetails.java RoomTy
    e.java ServiceAQHandler.java error=2

    Coskan,
    Sorry for annoying you...Since i cudnt
    reprodue the same error here in my machine, please provide
    following details also....
    1. Have you set the classpath environment variable correctly?
    Means all the jar files (Jndi.jar,ejb.jar,jta.jar,aqapi.jar,tools.jar, classes12.jar)are
    in classpath?
    2. Have you put <Oracle9i_Home>/bin in your classpath???
    Since sqlj.exe is in <Oracle9i_Home>/bin, this step is mandatory...
    Cheers
    --Venky                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Show Other Language instead of english when typing in TextField

    dears
    i want to make an application in which my user required other language specially
    URDU or ARABIC instead of english when typing in the textfield entries and then
    decode it(INTO ENGLISH) when save to the database.
    can i fullfill this task by using java?
    plz help me or give me soild refrenceses.
    thanks in advance

    In case this article doesn't give you the idea, machine language translation is far too complex to teach someone on a forum. You might check out amazon.com for books or search google for other articles, but you aren't going to learn what you need by asking here. The best you can hope for here is some links to books or online material. You might also check out universities in your area and see if they offer some kind of class which might be applicable.
    Here's a google search for language "automatic translation" "open source"
    http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=language+%22automatic+translation%22+%22open+source%22
    You might find some tools which will help, but I really doubt you will find a open source java translator (english<->urdu/arabic)

  • Cfc error

    I have a very simple page that contains a one cell one column
    table with no graphics (I am just developing the code for a project
    at this point. I have a cfinvoke statement passing a
    cfinvokeargument. Below is my code:
    <table width="500" border="0" align="center">
    <tr>
    <td>
    <cfinvoke component="cfcs.cmsContentForms"
    method="displayContent" returnvariable="displayContent">
    <cfinvokeargument name="contentID" value="1"/>
    </cfinvoke>
    </td>
    </tr>
    </table>
    It was running fine and then just today it began to kick up
    this error:
    Unable to complete CFML to Java translation.
    Error information unsupported statement: class
    coldfusion.compiler.ASTfunctionDefinition
    The error occurred in D:\www\CMS\contentDisplay.cfm: line 5
    3 : <td>
    4 : <cfinvoke component="cfcs.cmsContentForms"
    method="displayContent" returnvariable="displayContent">
    5 : <cfinvokeargument name="contentID" value="1"/>
    6 : </cfinvoke>
    7 : </td>
    Any one have any ideas at all what the heck this means. I
    can't find anything online about it and as far as I can tell my
    code is good.
    Thanks,
    Jason

    Thanks,
    Tried both of those and got the same error:
    Error information unsupported statement: class
    coldfusion.compiler.ASTfunctionDefinition
    The error occurred in D:\www\CMS\contentDisplay.cfm: line 4
    2 : <tr>
    3 : <td>
    4 : <cfset componentObj =
    createObject("component","cfcs.cmsContentForms")>
    5 : <cfset displayContent =
    componentObj.displayContent(1)>
    6 : </td>
    I had it working at one point so I may just have to start
    again at square one and re-develop it until I break it again to
    know what I did (or until it works and then wonder what the heck I
    did the first time).
    Has any one else ever run into this error? It is very
    unhelpful as far as identifying the source of the problem!

  • Delegation vs. Inheritance UML examples

    Hello,
    I'm currently trying to look into the differences between inheritance and delegation in java.
    From the articles I've read I think I understand the difference - having read their explanations and java code (that inheritance is the static placement of superclasses above subclasses at compile-time, which is rigid, whilst allowing for the inheritance of attributes/operations... yet delegation involves dynamically REFERENCING a subclass' superclass for methods, which means the referenced delegate can be changed in the future...)
    However, I'd be interested in looking at some examples with proper UML diagrams, but can't find anything on the internet...?
    Any got anything for a beginner who only just this morning began reading up on delegation vs. inheritance?
    Thanks!
    Sarah.

    Here would be my 2 cents worth. One nice (irritating?) thing about OOA/OOD is that there are many relatively correct design solutions to a given problem. What makes one better than another is usually not functional requirements (like compute a value), but non-functional requirements (like performance, security, extensibility...)
    Anyway, consider that you are designing the game of Scrabble. Each player has a tray that can hold 0-7 tiles. The main purpose of the tray is to hold a collection of letter tiles. Your first impulse might be to use inheritance. Rack is a subclass of ArrayList.
    | ArrayList | Pick your favorite collection class.....
    ---- (this is supposed to be a triangle)
    |
    |
    | Rack |
    Translated to Java
    public class Rack extends ArrayList
    The disadvantage is that you are exposing the entire interface of an ArrayList through your Rack. That may or may not be desirable. Say the customer calls up and wants to now have super scrabble, and you need to use a HashMap to look up data, then changing the super class could break alot of your code.
    Alternatively, we could hide all knowledge of how letters are stored (or even if they are stored). We only know that we can put letters in, and take them out and look at them. In the background we will delegate responsibility for storing these letters to some other class. Our UML might look like:
    --------------- Stores 0..7 --------------------
    | Rack | ____________________| Letters |
    How I store those letters is private. The implementor of Rack can
    use any data structure they want. The Java translation might be:
    public class Rack {
    private List<Letter> stores;
    Remember also that UML is just a tool to help you communicate design concepts within your team. If you spend more time on syntax than you do on actual design, it is no longer a help, it is a hinderance.
    Hopefully I have not confused you more....

  • Multi-lingual Translator component in java?

    hello all,
    I want to make a Multi-lingual Translator component in java
    which can be used to convert any existing web site(developed
    using any technology asp/jsp etc) to any foreign language
    viz german, spanish,italian and other major foreign
    languages.
    Please let me know how do i proceed in java with respect to
    the following?:
    1. It has to be developed as a component in java such that
    it can be included in any existing web site as a control
    which simply gives the users the option of converting
    either the current web page from english to any other
    foreign language or simply the entire web site from
    english to any other foreign language
         How to develop it as a component so that it can be
    independently merged into any existing web site(whether
    asp or jsp) as a control? which technology should i be
    using here EJB's or Applets or any other?
    I personally think it can be a applet because with EJB's
    container/application server is required.
    what do you all suggest?
    2. I don't want to use any free translators that are
    available freely on net these days, because a lot of them
    re-directs to their own translation page and includes
    their own banners and or advertisements etc., which may
    not be feasible with us as we have to include this
    utility on our company's web sites
    3. How much time it should take approximately to develop?
    4. If there's any free tool available however without the
    limitations as mentioned above in point 2, then i am not
    averse to using it please let me know if such a tool is
    available.
    5. Please also let me know if there exists already a multi-
    lingual component in java with source code freely
    available anywhere on net, then please give me the link.
    This will help me save a lot of time in developing it.
    Please let me know the answers to above of my queries and
    u"ll be doing a great deal of help here.
    Thanks in advance
    sd76

    JS supports UTF-8... assuming the browser has the proper fonts.
    // _lang.jsp
    <%@ page language="java" contentType="text/html; charset=UTF-8" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
         <title>Language Test</title>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body bgcolor="#ffffff" background="" text="#000000" link="#ff0000" vlink="#800000" alink="#ff00ff">
    <%
    request.setCharacterEncoding("UTF-8");
    String str = "\u7528\u6237\u540d";
    String name = request.getParameter("name");
    // OR instead of setCharacterEncoding...
    //if(name != null) {
    //     name = new String(name.getBytes("ISO8859_1"), "UTF8");
    System.out.println(application.getRealPath("/"));
    System.out.println(application.getRealPath("/src"));
    %>
    req enc: <%= request.getCharacterEncoding() %><br />
    rsp enc: <%= response.getCharacterEncoding() %><br />
    str: <%= str %><br />
    name: <%= name %><br />
    <script language="Javascript">
    alert('<%= name %>'); // should show correctly
    </script>
    <form method="POST" action="_lang.jsp">
    Name: <input type="text" name="name" value="" >
    <input type="submit" name="submit" value="Submit POST" />
    </form>
    <br />
    <form method="GET" action="_lang.jsp">
    Name: <input type="text" name="name" value="" >
    <input type="submit" name="submit" value="Submit GET" />
    </form>
    </body>
    </html>

Maybe you are looking for