Pls help.JSP: I could not store Chinese characters into files.

Hi experts,
I have this problem of cant store chinese characters into files(eg. .txt and .properties). I am adding
these chinese text through a JSP website form....After i key in chinese characters in the textboxes
in the website and sumbit the results, my chinese characters turned into ASCII or rather garbage in
the files.
Is there any way i can get the exact chinese characters i entered in the webite into the files?
Need urgent assistance here.
Thanks
<%@ page contentType="text/html; charset=big5" %>
<html>
<head>
<title>Confirmation</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
</head>
<%@ page language="java"%>
<%@ page import="java.io.*"%>
<%@ page import="java.lang.Integer.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.ResultSet.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.net.URL"%>
<%
//getting attributes from previous page form
//At this point, chinese characters r retrieved
//Ascii/garbage displayed for text when retrieved from previous page.
String gameName=request.getParameter("name");
String encode=request.getParameter("encode");
String gameType=request.getParameter("type");
String info=request.getParameter("description");
int check=0;
int nextGameID;
String temp="";
String langCode="";
//establish connection
Connection con = null;
try {
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection("jdbc:postgresql://172.20.134.110:5432/smsINTFET" , "postgres",
"postgres");
catch(ClassNotFoundException e) {
out.println("Could not load the driver: "+e.getMessage());
catch(SQLException e) {
out.println("SQLException caught in relax db: "+ e.getMessage());
Statement stmt = null;
ResultSet rs = null;
ResultSet ps = null;
String strSQL = "";
String strSQL2 = "";
String tempCat = "";
strSQL="SELECT gamename FROM cp_games order by gameid;";
try {
stmt = con.createStatement();
rs = stmt.executeQuery(strSQL);
stmt.close();
catch(SQLException e) {
out.println("SQLException caught: "+ e.getMessage());
while(rs.next())
check=0;
temp=rs.getString("gamename");
if(temp.equalsIgnoreCase(gameName))
// there is similar record in database
check=1;
break;
else
check=0;
if(check==0)
%>
<body background="button/bkgd.jpg" bgproperties="fixed">
<p><b><font size="30pts" face="Monotype Corsiva">Confirmation</font></b></p>
<HR style="WIDTH: 500px; COLOR: blue; HEIGHT: 3px">
The following information has been added.
<table width="75%" border="0" cellspacing="0" cellpadding="2">
<%
String strCat="";
strCat="INSERT INTO cp_games(gamename,description,encode) values('"+gameName+"','"+info+"','"+encode+"');";
stmt = con.createStatement();
stmt.executeUpdate(strCat);
System.out.println("Successful inserted category");
stmt.close();
//setting language
if(encode.equals("ascii"))
langCode = "US";
if(encode.equals("ms950"))
langCode = "TW";
if(encode.equals("ms936"))
langCode = "CN";
strSQL2="SELECT gameid FROM cp_games where gamename = '"+gameName+"';";
try {
stmt = con.createStatement();
ps = stmt.executeQuery(strSQL2);
stmt.close();
catch(SQLException e) {
out.println("SQLException caught: "+ e.getMessage());
ps.next();
nextGameID=ps.getInt("gameid");
out.println("<B>The game number : </B>" + nextGameID);
%>
<tr>
<td><B>Game added: </B><%=gameName%>
</td>
</tr>
</table>
<%
String newFile="G:\\home\\smsGamesINTV2\\colorGame\\propertiesFiles\\FET\\CP_Game"+nextGameID+"_"+encode+"_"+langCode+".properties";
try
{               //begin file
PrintWriter outFile=null;
//create a new file and write the initial settings to file
outFile=new PrintWriter(new FileOutputStream(newFile,true));
outFile.println("game_intro="+nextGameID+")"+gameName+" - "+info);
outFile.println("");
outFile.println("game_title="+gameName);
outFile.println("");
outFile.println("game_type="+gameType);
outFile.println("");
outFile.println("qns_no=0");
outFile.println("");
outFile.println("ana_no=0");
outFile.close();
}//end file
catch(IOException e)
out.println("File Create Error");
else // no match found
out.println("Game,"+temp+ " already added");
%>
</body>
</html>

try to add this code under this line:
<%@ page contentType="text/html; charset=big5" %>
<% response.setContentType("text/html; charset=big5"); %>
I have faced the problem like yours and it works fine for me. Try and see.

Similar Messages

  • Error help- "the operation could not be performed ...file... doesn't exist"?

    Hi,
    I am experiencing some probmels with ICE and can't find a reason for why.  I was able to edit the pages on the site through ICE about a month ago, but the client just let me know they can't do anything for any page.  I also can't do anything for any pages I was able to previously edit.  Basicall, I get this error message after being able to log in, edit page, and click save draft/ changes I get the following error:
    "The operation could not be performed because the file can't be accessed or doesn't exist..."
    I have looked extensively at these threads: http://forums.adobe.com/thread/444356?tstart=60
    and http://forums.adobe.com/thread/432559?tstart=0
    From that I have tried the following:
    Made sure passive FTP was working properly
    Verified FTP Dreamweaver connection with same FTP account: all is good and i can change and put the pages in question on the server.
    Verified tags in page (I think I have most pages correct.- although I know some are still not div tagged correct, but don't think thee issues are related.)
    verified that the directory settings on the adobe account (which is the root) is only "/"
    Tried editing in both Safari and FF and the client tried in IE and FF (all most recent versions I think)
    No progress has been made.  Actually now my adobe account for managing my sites is not allowing me to manage "settings" for this site either.  The tab is there but doesn't have the word settings on it and therefore I can't click it anymore
    Here is the site: www.extremecommunitymakeover.org.  I know for sure I WAS able to edit the index, get involved, and contact us pages a moth ago and now I get the error.
    Also- another maybe related problem is that I can't actually duplicate or create new pages via ICE.  Everything I try to name the new page gets kicked back and the dialog box says error says the "file extension is invalid".
    So- I seem to have a couple problems possibly all related to each other and your help would be much appreciated.
    Thanks,
    Sean

    Here's the setup on the two machines in particular...
    Machine #1:
    XP Pro
    Was IE7, now latest FF
    No antivirus
    Firewall – Windows Firewall, Downloaded AVG free trial ver., but not installed
    Machine #2:
    XP Pro
    IE7
    Again, No AV… had Kaspersky… but uninstalled it
    Windows Firewall
    Maybe that could be of some assistance... not seeing anything that could possibly block or inhibit the ICE. Each machine is independent of the other, separate networks, different locations, JavaScript enabled, no cookie blockers, etc.
    ....STUMPED!!!   

  • Help please! "Could not save as *** because the file...."

    I'm getting this error message when I try to save my files and it is happening often enough that it bothers me. This is very sudden - within the last week or two. I have Photoshop CS5, using Windows 7. I get the error message "Could not save as *** because the file is already in use or was left open by another application."
    I haven't done anything new to my computer or installed anything new, I've been using CS5 successfully since this summer when I first installed it on this brand new computer. Not sure why it's doing this now.
    When it happens, it does leave a .tmp file behind with each instance. I saved one this time just in case it's needed to determine the problem - normally I just delete it and try again. When I try multiple times, it eventually saves. But when I'm a professional photographer and have 100's of images to save, I just can't deal with this problem. Can anyone help? I'd be grateful!

    Are you saying you've disabled Spyware Doctor and it now works?  I'd toss that software out in a heartbeat if so.  Anti-malware software that interferes with your normal operation of your computer is not something to be accepted!
    Microsoft's Windows Defender is a decent substitute.  I also personally prefer Avast Pro antivirus.  Both are unobtrusive.
    -Noel

  • Illustrator CS6 does not store the last opened files

    I need Help,
    Illustrator CS6 does not store the last opened files.

    THat indicates a permissions issue on your preferences file and/ or your files are stored on some external or network device that doesn't use persistent file paths. Look into that.
    Mylenium

  • HT1414 the iphone software update server could not be contacted.a duplicate file name was specified , please help as this is driving me nuts,does anyone know which file it could possibly be ?

    Hi could anyone help me out? my iphone 3gs keeps restarting itself every two minutes which i think is some kind of software issue,now there are a number of things i have done starting with putting in a new battery.when i charge the phone it resets itself every two minutes or so and the battery indicator stays at 4% so i decided to restore the phone on itunes (which is the latest edition) and when i connect my phone which i have put into recovery mode using the buttons, i get an error message saying :- the iphone software update server could not be contacted.a duplicate file name was specified. i have tried re-installing i tunes and that doesn't solve the issue and i have trawled through the program files to see if i could spot the duplicate but without success ,has anyone had the same issue and resolved it?

    An iPhone 3G cannot be updated beyond iOS 4.2.1...that's the end of the line for your phone.

  • Anyone, pls help - my ipad is not opening, only apple logo is flashing on and off... :( pls help

    anyone, pls help - my ipad is not opening, only apple logo is flashing on and off... pls help

    Have you tried rebooting your iPad?
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.
    If that does not work, you can try restoring your iPad iOS Software.
    iTunes: Restoring iOS software - Support - Apple
    Make sure that you read the article all the way through and pay attention to the last part that talks about using recovery mode.

  • JSP Registry could not locate runtime property file

              At runtime, my JSP is throwing an exception claiming to be not able to find the property
              file. I have found the exact property file in the jar located on the server. I've
              tried extracting it and placing it in different places and adding the file and directory
              to the WebLogic classpath. I'm not sure what else to try.
              Here's the exception:
              Loading from CLASSPATH cat_test4_cat_pkg_Cat_pkgModule.properties
              java.lang.RuntimeException: JSP Registry could not locate runtime property file:
              cat_test4_cat_pkg_Cat_pkgModule.properties
              at java.lang.Throwable.fillInStackTrace(Native Method)
              at java.lang.Throwable.fillInStackTrace(Compiled Code)
              at java.lang.Throwable.<init>(Compiled Code)
              at java.lang.Exception.<init>(Compiled Code)
              Thanks.
              

    When you generate a webapp or use the JSP element wizard , a property file is created for you that contains some startup parameters. This file needs to be available in the classpath. This errors comes up becuase the file is not avalable in the classpath.

  • I am upgrading from Tiger to SL in a MCBPro with 2 gb ram and an intel chip and I get the following notice:  Installation failed.... THE INSTALLER COULD NOT COPY THE NCESSARY SUPPORT FILES. Any help is apprciated

    I am upgrading from Tiger to SL in a MCBPro with 2 gb ram and an intel chip and I get the following notice:  Installation failed.... THE INSTALLER COULD NOT COPY THE NCESSARY SUPPORT FILES. Any help is appreciated...

    Yes.   I've found that works best.  Especially if the drive is external, since external connections are typically slower, and Spotlight loves to eat up space going back and forth.   Time Machine will eat up as much space as it can, and typically needs drives at least twice the size of the original hard drive that is being backed up, if being backed up in full.   So unfortunately there is a lot of empty space that is needed for smooth operation.

  • Error Message: java.lang.RuntimeException: JSP Registry could not locate runtime prop

    Hi there
    Running Oracle Enterpride Edition 8.1.7
    including Oracle Http webserver
    I'm trying to run a JSP application developed with Jdeveloper
    through th http server
    Think I have modified alle the .conf files correctly
    I get the message :
    "Error Message: java.lang.RuntimeException: JSP Registry could not locate runtime property file:ORDERS_ORDERS_PKG_ORDERS_PKGModule.properties"
    Any ideas ?
    Or can anyone point me to a (proper) document that decribes (correctly and completely) alle the steps that need to be done ?
    Many Thanxs
    Regards TJ
    null

    I am also experiancing this problem. I have updated the ojsp to version 112200 and the properties file exist within the .jar used by the .jsp file.
    Exception:
    java.lang.RuntimeException: java.lang.RuntimeException: JSP Registry could not locate runtime property file:deseweb_DesewebModule.properties
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.(Compiled Code)
    at java.lang.Exception.(Compiled Code)
    at java.lang.RuntimeException.(RuntimeException.java:47)
    at morenet.jsp.JSPApplicationRegistry.registerApplicationFromProperties(JSPApplicationRegistry.java:199)
    at morenet.jsp.MorenetWebBeanImpl.internalInitialize(MorenetWebBeanImpl.java:119)
    at oracle.jdeveloper.html.WebBeanImpl.initialize(WebBeanImpl.java:56)
    at oracle.jdeveloper.html.DataWebBeanImpl.initialize(DataWebBeanImpl.java:395)
    at morenet.jsp.MorenetWebBeanImpl.initialize(MorenetWebBeanImpl.java:62)
    at apps.deseweb._index._jspService(_index.java:71)
    at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
    at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
    at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
    at oracle.jsp.JspServlet.internalService(Compiled Code)
    at oracle.jsp.JspServlet.service(JspServlet.java)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
    at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
    at org.apache.jserv.JServConnection.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)

  • Please help, my iPod could not backing up on iTunes.

    Please help, my iPod could not backing up on iTunes. It always says, "iTunes could not back up the iPod because the backup was corrupt  or not compatible with the iPod.  Delete the backup for this iPod, then try again." What's wrong with my iTunes??

    look at the brightside at least your computer sees yours

  • Help! Ever since I upgraded to Mavericks 3 months ago, I could not anymore log in into my TD Easy Web. Can somebody help?

    Help! Ever since I upgraded to Mavericks 3 months ago, I could not anymore log in into my TD Easy Web. Can somebody help?
    ~Amy

    Only your bank can tell you why your login is being rejected. Apple doesn't have acces to their servers. Are you certain you have the correct login credentials?
    If so, make sure Keychain isn't loading an old password by deleting the password entries for your bank from your login keychain in Keychain Access.

  • IPhoto9: "library could not be opened because the file system of the library's volume is unsupported."

    Can please anyone help me with this issue.
    After upgrading from iPhoto8 to iPhoto9 my library won't open anymore. I have stored all my pictures on a NAS (Buffalo Link Station Duo). It all worked fine but since upgrading to iPhoto9 I do have the following problem:
    When opening iPhoto I receive a message that the library needs to be updated. I assume that iPhoto should just do this sort of automatically in order to upgrade to iPhoto9.However, next message I receive then is
    "The library could not be opened because the file system of the library's volume is unsupported."
    Apple support so far does not seem to be able to solve my issue. Anyone else having had the same issue and having a solution to this?
    Thanks a lot for your help.

    There is no solution.
    IPhoto needs to have the Library sitting on disk formatted Mac OS Extended (Journaled). Users with the Library sitting on disks otherwise formatted regularly report issues including, but not limited to, importing, saving edits and sharing the photos.While you have been lucky to date, many folks with a library on a NAS found that it worked for a while and then the problems started.
    Workaround: Put the Library on a Disk Image formatted Mac OS Extended (Journaled) and store that on the NAS. But the real solution is to use a properly formatted disk for the Library.
    Regards
    TD

  • Cannot Store Chinese Characters In Oracle 9.2.0.7 Database

    Hi,
    I'm having trouble localizing my Oracle 9.2.0.7 / ASP web application for our Chinese-speaking users.
    My Oracle 9.2.0.7 Database has NLS_NCHAR_CHARACTERSET set to AL16UTF16.
    I've set up a test table thus:
    CREATE TABLE "TBL_TEST_CH"
    field1                          NVARCHAR2(40),
    field2                          NVARCHAR2(40)
    I have the Chinese character set installed on my database / web server (same box), as well as a test client machine. I can see Chinese characters in my web browser, and can enter them in a test ASP page I've set up. When I execute an insert statement via ADO, the insert statement seems to work, but the result is that the data seems to be stored as upside-down question marks.
    I thought perhaps the data was being somehow scrambled between the web app and the database, so I set up an external table import the Chinese data from a Unicode text file:
    CREATE TABLE kenny.ch_import
         FIELD1          NVARCHAR2(255),
         FIELD2          NVARCHAR2(255)
         ORGANIZATION EXTERNAL (TYPE oracle_loader
         DEFAULT DIRECTORY ext_dat_dir
         ACCESS PARAMETERS
         (RECORDS DELIMITED BY ":"
         FIELDS TERMINATED BY "~"
         missing field values are null)
         LOCATION (ext_dat_dir:'test_ch.txt'))
         reject limit unlimited
    However, when I query the data in the external table using my web application, it comes back with garbage like "ÿþ1" and the like.
    To attempt to determine if the database is capable of storing the Chinese characters, I've performed the following test:
    1) I insert a Chinese character in an NVARCHAR2 field in my table by using the UNISTR function thus:
    insert into tbl_test_ch (field1) values (unistr('\3E00'))
    2) I interrogated the value using the dump function thus:
    select dump(field1, 1016) FROM tbl_test_ch
    I'm struggling to understand the output. Obviously the character set being used is "AL16UTF16" (which I would expect to be able to store Chinese characters), but the return_format argument I've provided to the function (1016) should return the hexadecimal code point of the character that's being stored. I would expect this to be the same as I inserted ("3E00"), but I'm getting the following output:
    DUMP(FIELD1,1016)
    Typ=1 Len=2 CharacterSet=AL16UTF16: 3e,0
    I'd really appreciate any suggestions on what I could do next to determine exactly where the problem lies. I've not been able to convince myself that the database is correctly storing the Chinese character data, but I appreciate equally that the problem could lie elsewhere.
    Thanks in advance,
    Kenny McEwan.

    Thanks, Serguisz.
    My technology stack is as follows:
    ASP 3.0 web application, running on IIS6.
    On the web servier, I have MDAC 2.8 SP2 on Windows Server 2003 SP1.
    On the Oracle database server, I have Windows Server 2003 SP1.
    My Oracle database version is 9.2.0.7.
    The client I've been using in this investigation is Internet Explorer 6.0.2900.
    It does look like you're right about characters coming from the application are being corrupted. To support this, I tried to insert the chinese character 博 as well as the Unihan character 中 from a web page in my application. I then used the dump function to interrogate the contents of the field I input to thus:
    select dump(field1, 1016) FROM tbl_test_ch
    DUMP(FIELD1,1016)
    Typ=1 Len=2 CharacterSet=AL16UTF16: 0,bf
    Typ=1 Len=2 CharacterSet=AL16UTF16: 0,bf
    Both characters seem to have suffered the same corruption.
    The problem seems to happen in the other direction as well - even after verifying that the character detailed in the previous post was stored correctly, it is still displayed by my web app as an upside down question mark.
    Do you have any suggestions on how to proceed?
    Best regards,
    Kenny.

  • Pls Help me with steps to add data from xml file to SAP B1 through B1iSN.

    Pls Help me with steps to add data from xml file to SAP B1 through B1iSN. I  am getting stuck in xsl transformation. not able to understand where the mapping code needs to be added.
    Pls explain me the steps for adding data from xml to B1 quotation step by step.
    thanks and regards
    Priya

    Hi,
    Have you checked this: https://sap.na.pgiconnect.com/p45508295/?launcher=false&fcsContent=true&pbMode=normal ?
    Thanks,
    Gordon

  • Could not initialize Photoshop because the file is locked

    I have the problem where you get the Could not initialize Photoshop because the file is locked, where the solution was to fix the properties in the jpg. I did that and tried the Ctrl-Alt-Shft thing too. I pressed them in time and got the message to delete the settings. When I click yes, I still get the "file locked" message. If it is the scratch disk setting problem, I can't get PS open to change it. This problem started when I was opening a locked jpg from a relative. (Now none of my previous pics will open either). Any other ideas other than these that are already listed in the forums? Thanks for any help.
    Technical: Windows XP 5.1, HP7680, Photoshop CS2, 2g ram, more than enough work drives. (no Vista)
    Sequence of events: 1) recd a jpg from a relative in an email and saved it to hard drive. 2) with Photoshop unopened, I rt clkd on the jpg and chose "open with CS2". 3) PS started loading and then stopped with the "file locked" msg. Clkd on OK and PS closed. 4) tried to open PS from the shortcut (and from explorer) and got same result. 5) researched the problem and then used the Ctrl-Alt-Shft approach, got the window that asks to "delete settings" and chose ok, PS closed again. 6) went to the jpg and displayed properties and saw "This file came from another computer and might be locked....", so I clicked "unblock". 7) retried step 2, then 4 with same results. 7) tried to open an old jpg with step 2 and same result (got file locked msg). 8) no longer can bring up the "delete settings" window with the the Ctrl-Alt-Shft approach as it looks like it deleted the settings the 1st time.
    Any ideas???? Thanks again.

    Bob,
    I do not know why a locked JPG would mess up PS. I could see if you always tried to launch PS, by dbl-clicking on the JPG in Windows Explorer, but not from your Desktop shortcut, or from the PS.exe file.
    For the locked file, there is a freeware utility, Unlocker. I do not have a URL handy, but Google should find it for you. It has worked on some network assets, that seemed to lock up on me.
    Good luck, though this might not address your PS launch issue.
    Hunt

Maybe you are looking for

  • Oci post varray of blobs  to the database - any ideas?

    This seems wierd to me and i can't help thinking I'm missing something obvious. I can create a varray of blob on the db - called say "varrblob"; I can create an array of blob(string) in PHP; I can get multiple blobs from the db in one go via a cursor

  • Converter for String data

    Hello. Java Studio Creator 2 update 1. I'm trying to create Converter that converts Table data column of String type to other string representation. For example convert through ResourceBunde. But I've found that none of converters won't be used when

  • How to get Data Source Name and Source System for InfoPackage

    Hello Guys, I'm creating a routine that can be use by any InfoPcakges... how can I get the Source System and Data Source in a Routine?

  • PowerPivotConfigTool has stopped working

    hi when I run PowerPivot Configuration tool for the second time(first it ran perfectly), I get this error message while it's in the "Examining your system. Please wait..." problem details: Problem signature:   Problem Event Name:    BEX64   Applicati

  • Updating Ipod Version on Itunes.

    So when I get on I get these messages to update the itunes to like 6.0.4. Should I? Do I lose all my songs? My itunes has been funny lately. Windows XP Dell   Windows XP