Displaying japanese chars using servlet (posted in Java programming too)

I am trying to display the japanese characters inputed by the user using
html form and I am using servlet...
After reading the input and when i try to display i get ????
how can i solve this.
It was originally posted in Java Programming forum. but i think the question suits here....heres the link for original post
http://forum.java.sun.com/thread.jspa?threadID=670419&tstart=0
sorry for posts at two different forums

After reading the input and when i try to displayDisplay on what?
Usually, if request.getCharacterEncoding() doesn't return viable result, then you should call
request.setCharacterEncoding() with a proper value. If user send Shift_JIS string as form
input, then the argument value should be also "Shift_JIS". When in doubt, use "UTF-8".
Then, you call response.setContentType("text/html; charset="Shift_JIS"), etc.

Similar Messages

  • Calling servlet from a java program

    Hi
    I need to call a servlet's doPost() method from a java program. I have a specific situation, where I need to call servlet from a java program. DUring this call I need to pass a file and two string to the servlet. Servelt after receiving the file and string uploads the file to the server at a specified location. I am stuck up as how to call servlet from a java program instead of a HTML or JSP.
    Can anyone help me to start with this.
    any suggestion is welcome.

    You have to establish a URLConnection with servlet from your java program.
    URL servletURL = new URL("http://localhost:8080/Myservlet?str1=abc&str2=def");
    URLConnection servletConnection = servletURL.openConnection();you can get the objectOutputStream
    ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
    oos.writeObject(your file object);-------------------------------------------------
    In the servlet u can get the strings using request.getParameter("str1");
    In the servlet u can get the strings using request.getParameter("str2");
    file = new ObjectInputStream (request.getInputStream()).readObject()a lot of resources are available on this ...
    hope this helps :)

  • Can't use certain characters in java programs.

    For some reason I cannot use characters like: " ^ ~ | " in java programs.
    I can type them in a terminal and then paste them into the program, but cannot type them inside the java program - It's has been like that in every java application I have used. It only works when typing them in a applet running on a browser.
    Im running Linux RH 7.2 with JDK1.4.0 (It works fine in windows 2000)
    Hope somebody can help me.
    /Tommy

    Ehmm. What makes you believe that it isnt?
    I can't make exclusiveOr operations and if(bubba || bubba2) something....And that is a problem / annoyance.
    I can type every other characters but those ��� works fine as well.

  • Problem displaying Japanese char set in JEditorPane

    Hi ,
    I am using JEditorPane for displaying html content. If the content is in English
    it is getting displayed properly . In case of Japanese char set like Shift-JIS only square
    boxes is displayed .
    I have tried the following
    1.Installed Japanese font and set regional and language options.
    2.set content type of JEditorPane as text/html and char set=Shift-JIS
    3.Used InputSteamReader for reading html document .While constructing passed char set also.
    4.Used SetText to set html content.
    5.verified font.properties file
    I am Using JDK 1.4.2
    No positive results.
    Kindly help me to resolve this . If it known bug please inform.
    U can connect me at [email protected]
    Thanks in Advance,
    Polu

    Hi,
    Thanks,
    I have tried the approach has mentioned above but still no positive result,
    Pls can u guide me ,so as to what might be the problem,
    Cheers,

  • How can I use Servlets on Sun Java System WebServer 6.1

    Hi
    This is Khurram,
    I have just downloaded, and installed "Sun One Java System Web Server 6.1" on WindowsXP. This is installed and working properly on my system. But I want to use Servlet technology on this server, even I did download it just for working on servlets. Before it, I was using typical JavaWebServer2.0 for this purpose.
    Any ways.
    Can any one tell me, how can I do this on "Java System Web Server 6.1".
    Thanks
    any help will be appriciated
    regards
    Khurram

    Thanks for your such action.
    Actually I have installed it since 2 days, and have read throughly the documentation of WebServer, But Only the Link for this purpose is provided "Programmer's Guide to Web Applications", Now I have just searched for it and found only "Programmer's Guide" .PDF format. I have just read it out now, But here also provided a small refference to see "Programmer's Guide to Web Applications". Now I have just the problem that where to find it.
    Please, tell me if you have some solution to my problem
    or atleast tell me where to find the refference "Programmer's Guide to Web Applications". I tried but only found "Programmer's Guide" for Sun Web Server 6.1.
    Thanks any way to give some time.
    Khurram

  • Calling a servlet from a java program

    I could not find a forum for servlet hence am posting
    here
    I have a servlet that accepts prameters and
    gives some out put .
    I want to be able to call this servlet ( invoke )
    from a Java Program .
    How do i do that ..
    Any sample code /pointer would be appreciated.
    Deepa

    hi
    you can try this code.
    URL url = new URL("http://localhost:8888/yourServlet?param1=value1");
    URLConnection con = url.openConnection();
    StringBuffer sBuf = new StringBuffer();
    BufferedReader bReader = new BufferedReader(
    new InputStreamReader(
    con.getInputStream()));
    String line = null;
    while((line = bReader.readLine()) != null) {
    sBuf.append(line);
    System.out.println(sBuf);
    hope this helps
    Shrini

  • Use of netweaver in java programming

    Hi!
       I want to know the use of netweaver in java application as compare to other IDE's.
                        Thnk u

    Hi!
    I guess you mean the NetWeaver Developer Studio (NWDS) - which is the IDE - and not the NetWeaver Platform. The NWDS gives you access to the Java Development Infrastructure allowing to manage the lifecycle & delivery of applications, supports SAP specific project types like Web Dynpro, Portal Development, Mobile Applications, Dictionary aso.
    Like other IDEs it offers support development and deployment of J2EE-applications (EJB, Web), but only works with SAPs J2EE-engine.
    To be honest I don' t think there' s a reasonable comparison to other IDEs possible. You get more information from the development manual on help.sap.com.
    Regards,
    Thomas

  • How to Use native keyword in java programming

    Hi ,
    I am using JDK 1.6.0_11 , and i was trying to create a java program using "native" keyword ,
    i got the sample code for the same from the site : - http://www.javaworld.com/javaworld/javatips/jw-javatip23.html
    But when i type this command " C:\javah -stubs Happy " following error occurs
    " Error: JNI does not require stubs, please refer to the JNI documentation. "
    then typed " c:\javah -jni Happy" without any error .
    After that i wrote a HappyImpl.c as mentioned in the above tutorial
    #include <StubPreamble.h> /* Standard native method stuff. */
    #include "Happy.h" /* Generated earlier. */
    #include &ltstdio.h> /* Standard C IO stuff. */
    void Happy_printText (struct HHappy *this)
    puts ("Happy New Year!!!");
    then it is not compling and error is
    "unable to open included file StubPreamble.h file
    unable to open included file Happy.h file "
    Please help me . i want to use native method , i did exactly the same in tutorial at above link.
    Thanks & Regards
    Mannat

    you do need to know how to use your C compiler... It quite clearly can't find those files which indicates that you didn't tell it where to find them.

  • How can I use MS Word within java programming

    Hi everyone!
    I am developing a Java program that will take data
    from an Access 2000 database, and manipulate it,
    display the results graphically and in tables. The
    challenge for me is that I want the program insert the
    graphics and tables into the MS Word template and then
    prompt me to save it as a word * .doc. Do you know
    of any articles or sources of sample code on how to do
    this. The Java environment is Java2, JDK 1.3,
    JBuilder4. The OS environment is XP.
    Regards,
    Farad

    Hi, I also need that package. my e-mail is [email protected] Plese send me that. Thanks in advance
    I have a package that will do this for you. I just
    need to get your email to send an attachment and
    examples.

  • Using WD APIs in Java Programming

    Hi,
         First let me explain my scenario:
              I have to get the <b>attachments in a PDF document</b>, using a <b>java program</b>. I am using Java perspective of NWDS. I am using the APIs
    ->IWDPDFDocumentHandler
    ->IWDPDFDocumentAccessibleContext
    ->IWDPDFDocument
    ->IWDPDFDocumentAttachment
    in my program.
    When I run my java program, I am getting the <b>java.lang.NoClassDefFoundError</b>.  Can you please, give me a solution for this problem?
    Note :  I have added the necessary JAR files to the project.
    Thanks,
    Prabhakar.

    Hi Sumit,
       Here is the result which I got in the console,
    java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/services/exceptions/WDRuntimeException
         at PDFAttachment.readAttachmentFromPDF(PDFAttachment.java:241)
         at PDFAttachmentMain.main(PDFAttachmentMain.java:21)
    Exception in thread "main"
    Note :
    PDFAttachment
    - Class
    readAttachmentFromPDF
    - method
    The code is,
    String PDFDocName = "podetailswithAttachment.pdf";
                        //wdComponentAPI.getMessageManager().reportSuccess("Outside try FileName :"+PDFDocName );
                        try
                             //wdComponentAPI.getMessageManager().reportSuccess("Inside try FileName :"+PDFDocName );
                             FileInputStream fileInpStrm = new FileInputStream("C:\"+PDFDocName);
                             FileOutputStream fileOutStrm;// = new FileOutputStream()
                             ByteArrayOutputStream bo = new ByteArrayOutputStream();
                             int c;
                             while ((c = fileInpStrm.read()) > -1)
                                  bo.write(c);
                             byte[] pdfSource = bo.toByteArray();
    // Line :240     
                             IWDPDFDocumentHandler pdfdocHandler =WDPDFDocumentFactory.getDocumentHandler();
                             IWDPDFDocumentAccessibleContext pdfdocaccContext = pdfdocHandler.getDocumentAccessibleContext();
                             pdfdocaccContext.setPDF(bo);
                             IWDPDFDocument pdfDocument = pdfdocaccContext.execute();
                             IWDPDFDocumentAttachment[] pdfatt =   pdfDocument.getAllAttachments();
                             //wdComponentAPI.getMessageManager().reportSuccess("Length of the attachments: "+pdfatt.length);
                             //pdfdocaccContext.setPDF();
                        catch(Exception e)
                             //wdComponentAPI.getMessageManager().reportSuccess(""+e);
                             System.out.println(""+e);
    Thanks,
    Prabhakar.

  • JSP Unable to Load Class (posted in Java Programming for 5 Dukes)

    I hope this isn't a violation of forum etiquette, but I posted my question in Java Programming at http://forum.java.sun.com/thread.jsp?forum=31&thread=203255
    I realize now that it may have been wiser to post it here, but I have some replies already and it makes more sense just to inlcude the link.
    Can anyone assist with the question at http://forum.java.sun.com/thread.jsp?forum=31&thread=203255
    It's worth 5 dukes.

    Try changing <tagclass>E:\Tomcat324\jakarta-tomcat-3.2.4\webapps\examples\WEB-INF\classes\tags.ExampleTag</tagclass> to <tagclass>tags.ExampleTag</tagclass>
    because <tagclass> tag is for the class name and not the location of class file
    And make sure your ExampleTag.class file is in
    \WEB-INF\classes\tag\ExampleTag.class
    B!

  • Decrypt file using AES(32) by java program ?

    I have encrypted file using AES 32 bit and i have key. So I want to decrypt the file using Java program/ cryptography standards with that key.
    Anybody help highly appreciated.

    Yes that would make sense, cheers:
                 fw2.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
                 fw2.write("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
                   fw2.write("<html>");
                   fw2.write("<head>");
                   fw2.write("<title>Output</title>");
                   fw2.write("<link href=\"Styles.css\" rel=\"stylesheet\" type=\"text/css\">");
                   fw2.write("</head>");
                   fw2.write("<body>");
                   fw2.write("<div id='Border'>");
                   fw2.write("<div id='Background'>");
                   searchForSubFolder(file);
                   fw2.write("</div>");
                   fw2.write("</div>");
                   fw2.write("</body>");
                   fw2.write("</html>");This is working to some extent although the formatting from the css file is not working. Any ideas why this is? I am using divs determined by thee css to do things like the background colour.
    Thanks

  • Problem Displaying Japanese chars in MIDlet

    Hi,
    I want to internationalize my MIDlet application.
    For that I am using ResourceBundle ,it works fine with J2ME kit.I know it works fine because Jdk1.3 supports displaying unicode characters.I think KVM doesn't support unicode characters.If anybody knows something then please reply immediately.
    Regards
    Vivek

    [vivek_kurundkar],
    Currently MIDP v1.0 only states that the ISO Latin 1 character encoding must be supported by all MIDP implementation i.e. mandatory to support the ISO Latin 1 char encoding but not all other locales.
    The locale is defined in the microedtion.locale system proprety and localization must be provided by the implementation i.e. for example the device manufacturer who provides the kVM for their device.
    In your case, you have a need for the Japanese locale and thus the emulator/kVM of the device must provide the Japanese locale.
    Which kVM emulator/device are you testing your CLDC/MIDP application with?
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • DISPLAY SPATIAL DATA USING JDBC ON A JAVA FRAME

    I am trying to set up some spatial data and need help in getting some sample
    code for displaying the data on a Java Frame using JDBC.
    The shapes I am setting up are simple polygons, lines, circles. I was going
    through the samples in the demo directory under $ORACLE_HOME/md/demo/examples, but could not find any JDBC
    I would really appreciate if you can point me towards some sample code and any other spatial resources.
    Madhukar

    Here you go. It uses JDBC to fetch geoms, convert them into Java JGeometry objects, which then create Java2D shapes (these are functions of the public sdoapi.jar library). It then uses some class in the sdovis.jar library (the rendering engine of MapViewer) to setup the necessary viewport transform. If you know how to setup the viewport transform, then you dont even need sdovis. sdovis.jar is found in an deployed MapViewer's WEB-INF/lib directory. Or you can extract it from the mapviewer.ear's web.war file.
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import oracle.jdbc.OracleDriver;
    import oracle.sdovis.*;
    import oracle.sdovis.style.*;
    import oracle.sdovis.util.*;
    import oracle.spatial.geometry.JGeometry;
    import oracle.sql.STRUCT;
    * A very simple program that shows stuff from db in a JFrame
    * <p>
    public class tilsvgui2 extends JFrame
      final static int mapWidth  = 640;
      final static int mapHeight = 480;
      static JSDOGeometry geom = null;
      public tilsvgui2()
        setSize(mapWidth+40, mapHeight+40);
                    setVisible(true);
        this.addWindowListener(new java.awt.event.WindowAdapter() {
          public void windowClosing(WindowEvent e) { System.exit(0); }
            public void paint(Graphics g)
                    super.paint(g);
        int w = this.getWidth(), h = this.getHeight();
        Insets inset = this.getInsets();
        double[] mbr = geom.getMBR();
        //from sdovis; it will setup the viewport transform
        XFViewPort xfp = new XFViewPort();
        xfp.setDeviceView(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
        xfp.setDataView(mbr[0], mbr[1], mbr[2], mbr[3]);
        AffineTransform af = xfp.getAffineTransform();    //get the viewport transform
        Shape shp = geom.createShape(af);    //create a proper shape that fits the viewport
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.red);
        g2.drawRect(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
        //draw the shape itself
        g2.setColor(Color.blue);
        g2.draw(shp);
      public static void getStuff() throws Exception
        System.out.println("Loading geometry...");
        Connection conn = getConnection("mapsrus.us.oracle.com", "1521", "orcl", "scott", "tiger");
        Statement  stmt = conn.createStatement();
        ResultSet  rset = stmt.executeQuery("select geom, totpop from counties where county='Merrimack' and state_abrv='NH'");
        while(rset.next())
          STRUCT st = (STRUCT) rset.getObject(1);
          geom = JSDOGeometry.loadFromDB(st);
          int population = rset.getInt(2);
          break; //displaying only the first geometry
        rset.close();
        stmt.close();
        conn.close();
      private static Connection getConnection(String host,
                                              String port,
                                              String sid,
                                              String username,
                                              String password)
        throws SQLException
        String thinConn = "jdbc:oracle:thin:@"+host+":"+port+":"+sid;
        Driver d = new OracleDriver();
        Connection conn = DriverManager.getConnection(thinConn,username,password);
        conn.setAutoCommit(false);
        return conn;
      public static void main(String[] args)
        try{
          getStuff();
        }catch(Exception e)
          e.printStackTrace(System.err);
        new tilsvgui2();
    }

  • Using Runtime to execute java programs in Tomcat

    hi
    I have an application which I am trying to run from within a jsp. the following is the command when executing within jpadpro:
    "C:\j2sdk1.4.0_01\jre\bin\java.exe" -classpath \\Stuweb3\home\jsp\WEB-INF\classes;C:\SQLLIB\java\db2java.zip FtpExample
    my code within the jsp:
    rt = Runtime.getRuntime();
    rt.exec("'C:\j2sdk1.4.0_01\jre\bin\java.exe' -classpath \\Stuweb3\home\jsp\WEB-INF\classes;C:\SQLLIB\java\db2java.zip FtpExample");
    and other combinations of forward and back slashes and single and double quotes but to no avail.
    please help

    Look closer at the api for the Runtime class. I did something much as you are that is, trying to build a great big string to set to the command line. There are methods wherein you build a String[] that becomes the arguments to the command shell, and this is eventually what I found to be the most flexible and workable solution. Just because you can type it on the command line does not mean it will work when you make it into one big string and pass it into the os. hope this helps

Maybe you are looking for

  • Sender IDoc adapter

    Hi all, I am trying some Idoc scenarios, and i find the IDoc sender radio button inactive in my system, do we configure the IDOc sender adapter in XI? if so can anybody send me a screen shot of the parameters we configure in the IDOC sender adapter??

  • PHP Form Filtering

    Hey Guys, I'm curious as to some of the best solutions to help filter out spamming through a php form.  Should I add captcha?  Is there another way?  I want to be able to filter out the erroneous requests or advertising of selling email lists from th

  • I have started having getting incomplete Cd recordings,missing parts of songs.

    About a month ago I started having problems with spaces in songs that were blank for the remaining time of that song and then the next song would start on the cd. This might happen 4 or 5 times during the rest of the cd. I never had this problem befo

  • Strange AirTunes problem

    A few days back, I ran Software Update and installed the latest version of iTunes (7.3.1) and a few other applications. Since then, when I open iTunes and try to stream music through my home surround speakers, it only plays through the right channel(

  • I need help burning a cd from keynote

    I need help burning a cd from keynote for a slideshow presentation on a tv