Internationalization/Unicode output from Servlets...

[att1.html]
          

After some help from others on this board, I was able to accomplish my
          goal of outputting Korean and Japanese characters to an IE5 browser from
          within a WLS v4.5.1-Service-pack-1 servlet.
          I have been able to output and properly display both Korean and
          Japanese characters from within a servlet running on WLS4.5.1 using the
          8-bit Unicode character set (UTF-8).
          Summary: Both straight text output, FreeMarker, and WebMacro were able
          to handle this simple example. I don't know what will happen if you
          try to use WebMacro's more advanced reflection capabilites, but I will
          try to test that also.
          First, you'll have to install the 'Japanese Language Support' and
          'Korean Language Support' for IE5 (obtained from the Windows Update
          site). This should only take a few minutes.
          Now try the following servlet. It should output Japanese characters:
          public void service(HttpServletRequest req, HttpServletResponse res)
          throws ServletException, IOException {
          res.setContentType("text/html; charset=UTF-8");
          PrintWriter out = new PrintWriter(new OutputStreamWriter(res.getOutputStream(), "UTF8"),true );
          String test = new String("<HTML><BODY>\u72ac\u72ac</BODY></HTML>");
          out.println (test);
          out.close();
          [att1.html]
          

Similar Messages

  • Robocopy unicode output jibberish log file

    When I use the unicode option for a log file or even redirect unicode output from robocopy then try to open the resuting file in notepad.exe or whatever, it just looks like jibberish. How can I make this work or when will Microsoft fix it? Since Microsoft put that option in there, one supposes that it works with something. What is the expected usage for this option?
    Yes, I have file names with non-ASCII characters and I want to be able to view them correctly. Without unicode support robocopy just converts such characters into a '?'. It does, however, actually copy the file over correctly, thankfully. I have tried running robocopy from PowerShell and from cmd /u. Neither makes any difference. Also, one odd thing is that if I use the /unicode switch, the output to screen does properly show the non-ASCII characters, except that it doesn't show all of them, such as the oe ligature used in French 'œ'. That was just converted into an 'o' (not even an oe as is usually the case). Again, it does properly make a copy of the file. This just makes it not quite possible to search log results.
    Let's see if this post has those non-ASCII characters transmuted when this gets posted even though everything looks fine as I type it. âéèïöùœ☺♥♪

    When I use the unicode option for a log file or even redirect unicode output from robocopy then try to open the resuting file in notepad.exe or whatever, it just looks like jibberish. How can I make this work or when will Microsoft fix it? Since Microsoft put that option in there, one supposes that it works with something. What is the expected usage for this option?
    Yes, I have file names with non-ASCII characters and I want to be able to view them correctly. Without unicode support robocopy just converts such characters into a '?'. It does, however, actually copy the file over correctly, thankfully. I have tried running robocopy from PowerShell and from cmd /u. Neither makes any difference. Also, one odd thing is that if I use the /unicode switch, the output to screen does properly show the non-ASCII characters, except that it doesn't show all of them, such as the oe ligature used in French 'œ'. That was just converted into an 'o' (not even an oe as is usually the case). Again, it does properly make a copy of the file. This just makes it not quite possible to search log results.
    Let's see if this post has those non-ASCII characters transmuted when this gets posted even though everything looks fine as I type it. âéèïöùœ☺♥♪
    Uses /UNILOG:logfile   instead of /LOG:logfile

  • Export unicode data to Excel from Servlet

    Hi,
    In my application we are export some unicode data to Microsoft Excel 2003 from servlet .
    For that i am using the following code.
    response.setHeader( "Content-Disposition", "attachment; filename=results.xls" );
    response.setContentType( "text/xls" );
    theHeader.append("\u30ec\u30dd\u30fc\u30c8 \u30bf\u30a4\u30c8\u30eb");
    The above unicode data (japanese character) not displaying properly in Excel (display as "?"). other non unicode things are display properly.
    can anyone advise me.

    I was having problems writing a unicode (utf-8 or utf-16) csv excel file, found a solution in the end ill post it here in case anyone else is looking.
    You need to use the funky encoding x-UTF-16LE-BOM
    an example of how to do this is
    Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile, true), "x-UTF-16LE-BOM"));
    then instead of using commas (,) use tabs (\t)
    then in my web.xml i have
    <mime-mapping>
    <extension>csv</extension>
    <mime-type>application/msexcel</mime-type>
    </mime-mapping>
    this site is a good reference
    http://members.chello.at/robert.graf/CSV/
    Hope this helps someone ! =]. I am using excel 2007may or may not work with earlier versions.

  • Sending  unicode data to Excel from servlet displayed as "?"

    Hi,
    In my application we are export some unicode data to Microsoft Excel 2003 from servlet .
    For that i am using the following code.
    response.setHeader( "Content-Disposition", "attachment; filename=results.xls" );
    response.setContentType( "text/xls" );
    theHeader.append("\u30ec\u30dd\u30fc\u30c8 \u30bf\u30a4\u30c8\u30eb");
    The above unicode data (japanese character) not displaying properly in Excel (display as "?"). other non unicode things are display properly.
    can anyone advise me.

    I was having problems writing a unicode (utf-8 or utf-16) csv excel file, found a solution in the end ill post it here in case anyone else is looking.
    You need to use the funky encoding x-UTF-16LE-BOM
    an example of how to do this is
    Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile, true), "x-UTF-16LE-BOM"));
    then instead of using commas (,) use tabs (\t)
    then in my web.xml i have
    <mime-mapping>
    <extension>csv</extension>
    <mime-type>application/msexcel</mime-type>
    </mime-mapping>
    this site is a good reference
    http://members.chello.at/robert.graf/CSV/
    Hope this helps someone ! =]. I am using excel 2007may or may not work with earlier versions.

  • WML Output From JSP/Servlets

    I need some assistance with WML output from someone who knows...
    I am writing a small subset of applications for mobile access. When testing them through the OpenWave Emulator (the UP browser) everything works just fine. However..the output varies greatly to where on some machines the login cannot be performed. My only problems tend to occur with forms and the lack of an <input type="submit"/> component.
    Here's the WML output of the login screen:
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
    "http://www.wapforum.org/DTD/wml12.dtd">
    <wml>
    <card id="login" title="Login Form">
    <p>Please login.<br/>
    <table>
    <tr><td>Username:</td></tr>
    <tr><td><input name="username" type="text" title="username"/></td></tr>
    <tr><td>Password:</td></tr>
    <tr><td><input name="password" type="password" title="password"/></td></tr>
    </table>
    </p>
    <do type="accept" label="Login">
    <go href="/portal/mobile/vendor/" method="POST">
    <postfield name="username" value="$(username)"/>
    <postfield name="password" value="$(password)"/>
    </go>
    </do>
    </card>
    </wml>Again, in OpenWave's UP browser, I can enter the username and password, then click options --> Login and things work great.
    However on the WinWap browser, I only get the labels, no input fields or login option.
    Does this WML look properly formed? Any help would be appreciated.

    I can't really tell you the fix, as I really can't remember, but I know I had a similar problem once... OpenWave was fine, but the Nokia emulator didn't like it.
    I think I ended up having a different DOCTYPE and having the username and password inputs on separate pages.
    Does WML support tables?

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • Multiple Input and Output from a 6534

    Hello
    I am after some advice regarding my PCI 6543 digital I/O card and the best way to achieve my desired results. I am programming in Visual C++ with Ni-DAQ 7.
    I want to generate a pattern output from one of the ports, Port A, following a software command. This pattern consists of a 10uS pulse on DIOA0, that repeats 200 times with a period of 100uS. I want this DIOA0 output line to initiate an input on ports C and D, possibly through the REQ pin. Consequently the input should acquire 200 times for each call to the pattern output.
    I want this to repeat, so the pattern output goes again (as in a FOR loop), and the input occurs again for an as yet undetermined number of times.
    I have managed to get something worki
    ng for 1 iteration, and I can generate multiple pattern outputs, but the inputs only seem to acquire for the 1st iteration. However, if I step through the code in debug mode I can get the input to work correctly.
    Any ideas would be gratefully appreciated.
    I am still trying to get some earlier problems with this application solved.
    Kind Regards
    Jamie

    Hi Jamie,
    There are a couple different ways you can loop from a buffer. You can either use the onboard memory of the 6534 and loop from there or you can specify as a software configuration that the board loop through the PC memory buffer.
    For the onboard looping you need to specify the following:
    iStatus = Set_DAQ_Device_Info (1, ND_PATTERN_GENERATION_LOOP_ENABLE, ND_ON);
    For software, PC memory looping, the following function specifies this:
    iStatus = DIG_DB_Config (iDevice, iGroup, 1, 0, 1);
    I attached a couple programs that might be of use. Check this post:
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=5065000000080000008BA10000&USEARCHCONTEXT_CATEGORY_0=_31_%24_12_&USEARCHCONTEXT_CATEGORY_S=0&UCATEGORY_0=_31_%24_1
    2_&UCATEGORY_S=0
    Hope that helps. Have a good day.
    Ron

  • Project output from Elements 9 cut in half?

    The file from project output from Elements 9 is cut in half.  What do I do.  You can only see the bottom half.

    Got it.  Removed KB2803821 and everything is working fine again.  Thank you very much for your help!
    Carmen LoParo
    Date: Sat, 20 Jul 2013 17:28:26 -0700
    From: [email protected]
    To: [email protected]
    Subject: project output from Elements 9 cut in half?
        Re: project output from Elements 9 cut in half?
        created by A.T. Romano in Premiere Elements - View the full discussion
    cloparo1
    It is there at the top of the forum
    It should look like
    http://helpx.adobe.com/premiere-pro/kb/wmv-files-corrupted-import-or.h tml http://forums.adobe.com/servlet/JiveServlet/downloadImage/2-5523906-365234/450-315/Announc ement.jpg
    The link in the screenshot will not be active since it is only a screenshot. If you cannot find the Announcement, the link the it gives is
    http://helpx.adobe.com/premiere-pro/kb/wmv-files-corrupted-import-or.h tml
    But it is there. So, please try again to find it.
    The following is a link  many, many recent threads on the problem.
    http://forums.adobe.com/message/5522906#5522906
    Please let us know if you find the information that you need and that you are OK with solution.
    Thank you.
    ATR
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5523906#5523906
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5523906#5523906
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5523906#5523906. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Premiere Elements by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to call any .tmpl file from servlet by sending some parameters ?

    Hi,
    I am new to Java Servlet and HTML template language ( anyfile.tmpl).
    I have created simple login authentication with user registration for new user.
    If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
    Thank you.
    if (session == null) {
         try {
              userName = request.getParameter("login");
              pwd = request.getParameter("password");
              if (!userName.equals("") && !pwd.equals("")) {
              try {
    //Database connection, data fetching, query execution etc.
    // code will go here
                   while (rs.next()) {
                   if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
                        String u_name = userName;
                        String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
                        String address = rs.getString("address");
                        session = request.getSession();
                        session.setAttribute("user", userName);
                        String inbox = context.getInitParameter(INBOX);
                        Template inboxTmpl = new Template(inbox);
    *                    inboxTmpl.setParam("userName", u_name);*
    *                    inboxTmpl.setParam("ph_no", ph_no);*
    *                    inboxTmpl.setParam("address", address);*
    *                    out.println(inboxTmpl.output());*
                        System.out.println("Login successful..");
                        break;
                   rs.close();
         pstmt.close();
    con.close();
    (P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}

    Where does Template come from?
    But its not working.The other day I called the car repair shop. I told them my car did not work and I wanted them to fix it. They asked what was wrong, whether it did not start, whether suspicious sounds were heard, whether the car did not want to brake any longer, whether it gave a smoke from the exhaustion, whether the wind shield was broken, whether the oil was leaking etc. But I insisted just telling them "it doesn't work".

  • How to call JSp from Servlet??

    Hello,
    I want to call JSP page from servlet.I am using Visual Age For java 3.4. What is wrong in my code??
    if (userExists) {
    f.setErrors("userName","Duplicate User: Try a different username");
    getServletConfig().getServletContext().
    getRequestDispatcher("/jsp/forms/retry.jsp").
    forward(request, response);
    I am not able to get the o/p. Pls help.

    I can't see anything obvious, but did you take any steps towards doing output before this code (like openning an output stream)?
    Not clear what f.setErrors does - presumably stuffs the error message in an attribute of the request.

  • Applet in jsp from servlet, but error: ClassNotFoundExcep

    The problem that I'm having is already mentioned a couple of times in this forum, but unfortunately I haven't found a solution, in thread http://forum.java.sun.com/thread.jspa?forumID=33&threadID=239405 is proposed solution but it's not working for me.
    I'm developing a project in IBM's Websphere Developer Studio 5.1.1. and JRE that I'm using for this project is 1.4.2. I have created servlet "CompanyDocument.java" and applet "SimpleApplet.java". Applet was created as single project and then imported into this one, that means that it's contained in current project as "SimpleAppletPackage.jar". I have placed jar in folder "Applets", Websphere automatically creates folder "simpleAppletPackage" and in it's root complied "SimpleApplet.class".
    When I put following code in the jsp page applet works correctly when application is runed.
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets" archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>
    But I wanted to create jsp from servlet. So I used this code within servlet:
    out.print("<APPLET code=\"simpleAppletPackage/SimpleApplet.class\" codebase=\"Applets\"");
    out.print("archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>");
    But I get an error (when running, no error when compiling). The error is copied from Java console:
    load: class simpleAppletPackage/SimpleApplet.class not found.
    java.lang.ClassNotFoundException: simpleAppletPackage.SimpleApplet.class
    at sun.applet.AppletClassLoader.findClass AppletClassLoader.java:162)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:123)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:566)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:619)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:548)
    at sun.applet.AppletPanel.run(AppletPanel.java:299)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: java.io.IOException: open HTTP connection failed.
    at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:265)
    at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:43)
    at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:152)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:149)
    ... 9 more
    In the same time I'm creating some more code from servlet and it works with no errors and is shown in browser properly (it consists of connection to Oracle, formatting table, and presenting data within that table).
    Any idea? I'm totally stuck.

    In your browser, look at the HTML code that gets sent to the browser and see if there is something wrong with it.
    Specifically, I would look at the code near the <APPLET ..></APPLET> tags, both before and after and look for stray quotes, brackets, or what not.
    Finally, I would look inside the <APPLET ...> tag. It appears to me that the output will probably be:
    <APPLET code="simpleAppletPackage/SimpleApplet.class" codebase="Applets"archive="SimpleAppletPackage.jar" width="250" height="250"></APPLET>See, you may be missing a space between the "Applets" and the archive=. Try making the second out.print look like this:
    out.print(" archive=\"SimpleAppletPackage.jar\" width=\"250\" height=\"250\"></APPLET>"); See the extra space at the start of the output?

  • How to execute package from Servlet

    Hi all...
    I have set of class files in a package called iDen_parser.
    My main class name is jump_calc..
    String[] cmd={"cmd.exe" , "/c" ,"java iden_parser.jump_calc","d:/test.log","d:/test.txt"};
    Runtime runtime = Runtime.getRuntime();
    process = runtime.exec(cmd);
    I am not getting any output...
    I have placed the folder Iden_parser in current working directory itself.
    While I when I am trying out simple program HelloWorldApp, it's working out fine.
    String[] cmd={"cmd.exe" , "/c" ,"java HelloWorldApp};
    Runtime runtime = Runtime.getRuntime();
    process = runtime.exec(cmd);
    So anyone ,pls help me out in executing the pakage from servlets
    Thnk
    VIjay

    Hi...
    I am placing my code here
    String path1 ="cmd /c dir /d";
    String[] cmd={"cmd.exe" , "/c" ,"java
    java HelloWorldApp"};
    String[] path ={"cmd.exe",null, "
    java iden_parser.jump_calc", "d:/test.log","
    d:/mygod.txt"};
    Replace....
    String[] path ={"java iden_parser.jump_calc", "d:/test.log","
    d:/mygod.txt"};
    Runtime runtime = Runtime.getRuntime();
    Process process = null;
    try {
    process = runtime.exec(path);
    Replace....
    process = runtime.exec(path, null, "the dir from where u call the stand alone program on command prompt");
    outHTML.println("PAth" +path);
    BufferedReader in =
    new BufferedReader(new
    er(new InputStreamReader(process.getInputStream()));
    // Read and print the output
    String line = null;
    outHTML.println("Something had happen");
    if((line = in.readLine()) == null)
    outHTML.println("Empty");
    while ((line = in.readLine()) != null) {
    outHTML.println(line);
    catch (Exception e) {
    outHTML.println("Did not execute the command
    command " );
    //out.println("Problem with finger: " +
    // ServletUtils.getStackTraceAsString(e));

  • Is the raw output from JSP and XSQLServlet the same?

    Hi
    Is there is difference between the raw output from XSQLServlet and JSP? For example, assuming the same content is being generated, is there some additional header information emitted by XSQLServlet that is not done by JSP?
    I am using software that successfully consumes generated content from a JSP OK, but the same content (using the same XML/XSL) generated from XSQLServlet is being rejected. I am puzzled by this. Maybe this is due to some differences in servlet output or an encoding issue? The content is not HTML but XML-like with an "application" contentType, like Steve's SVG example.
    It seems that XSQLServlet is showing some data prior to emitting the actual content, i.e. HTTP version, responding server version, content type and date, e.g.
    HTTP/1.0 200 OK^M
    Server: Resin/2.0.5^M
    Content-type: application/x-sky; charset=UTF-8^M
    Date: Thu, 28 Mar 2002 06:45:34 GMT^M
    ^M
    (then the generated content)
    Is this preamble usually generated by a JSP also?
    If not, can this information be turned off, or put another way, can XSQLServlet's raw output be set to be exactly like JSP? If not, is there a workaround?
    I have tried setting the following XSQLConfig.xml
    <suppress-mime-charset> for the mime-type &
    <character-set-conversion>
    <none/>
    </character-set-conversion>
    also, but to no avail.
    Please help! I really want to use XSQLServlet!
    Thanks.
    Michael.

    Yes, just less fine control over the process but the same engine.
    Regards
    TD

  • Calculate size of output from HttpServletResponse

    how to calculate size (in bytes) of the output from HttpServletResponse.
    can anyone tell me....
    thanks in advance

    > how to calculate size (in bytes) of the output from
    HttpServletResponse.
    can anyone tell me....
    1) Read the bytes from the servlet output stream and count them.
    2) Determine the content to be sent in the response and count the bytes.
    ~

  • Printing to java console from servlets

    Hi
    i would like to use the java console on the browser to display some debugging output from my servlets.
    using "System.out.println" would output to the server logs.
    is there any way to do this??
    -Eli-

    I know that there is a Jakarta TLD that does this, it's one of the Tomcat4.0.1 examples.
    <%@ taglib uri="http://java.apache.org/tomcat/examples-taglib" prefix="eg" %>
    <eg:log>
    Did you see me on the stderr window?
    </eg:log>
    <eg:log toBrowser="true">
    Did you see me on the browser window as well?
    </eg:log>Any visitor hitting the web site will not see the <eg:log> tags, however with the toBrowser="true" they will as well as you should see them on the console. Double check the TLDs on jakarta.apache.org to see what you can find. If you are using another Java Servlet container it's probably just a matter of changing a class file for the same functionality.

Maybe you are looking for

  • How can I safely purge my slow Safari?

    My edition of Safari, running under Mavericks 10.9.5, has been getting noticeably slow this last month or so, especially in resolving websites to screen. In fact, sometimes Safari will fail to acquire even a reliable site and will instead stall. I th

  • Can't drag objects out of Spotlight?

    I thought it would Just Work if I had a file chooser dialog open, say if I were uploading a file from Safari, and I looked up the file I wanted in Spotlight and dragged it into the file chooser. No go. I'm surprised; isn't this something it obviously

  • Connecting M2 to my PC

    I have been connecting my M2 to my PC to drop music tracks to my SD card. For the past few days PC companion is telling me my phone cannot be found. I've used all the troubleshooter tips IE Uninstalling PC companion, updating phone etc.The icon appea

  • SMC(Solaris Management Console) problem

    Hi I am trying to start SMC for managing the users and groups.But i am getting the following errors. bash-3.00# smc com.sun.management.viper.CriticalStopException: javax/help/JHelp at com.sun.management.viperimpl.console.gui.SMCConsole.start(SMCConso

  • Does this photo type gallery have a technical name?

    I am not sure if there is a technical name for this type of photo gallery or what, is it photo navigation or a flash banner, if any one knows where I could find a tutorial or fla I would surely appreciate it. Trying to finish up a site i have been wo