Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Y the jsp put out the hex codes?

Posted on 2001-08-02
10
Medium Priority
?
177 Views
Last Modified: 2010-03-31
Hi,

It should be some english words that retrieved from the oracle database.But now I got some hex codes.

I have defined the same character set on both server and client side.

I don't know what's wrong!

Thanks in Advance.

Vivian Qi

0
Comment
Question by:vivianQQ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344043
hi !! guess u've got to post some code in order for us to help u

:)
0
 

Author Comment

by:vivianQQ
ID: 6344060
0x3938E5BAA6E4B990E9989F 0x3938646567726565
 0x42656361757365206F6620796F75 0xE69CAAE79FA5
 0x3938E5BAA6E4B990E9989F 0x3938646567726565
 0x42656361757365206F6620796F75 0xE69CAAE79FA5
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344096
hahaha no the hex codes but the applet code...:)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vivianQQ
ID: 6344109
what is applet code?

I took for granted that it's the hex codes because they R all begin with 0x.

Anyway how to solve the problem?

ThanX
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6344114
i mean how u retrieve this codes from oracles....
using asp ??
or jsp ??
or applets ??
0
 

Author Comment

by:vivianQQ
ID: 6344156
lol,what a stupid mistake!

I use jsp+JavaBeans
the code that associated with them is listed below:
test.jsp

<%@ page language="java" import="ssei.*"%>
<%@ page contentType="text/html; charset=GBK"%>

<HTML>
<HEAD>
<jsp:useBean id="Searcher" scope="request" class="ssei.sseiBean" >
    <jsp:setProperty name="Searcher" property="key_Word" param="key_Word"/>
    <jsp:setProperty name="Searcher" property="key" param="key"/>
</jsp:useBean>
<title>test</title>
<body>
    <%
     String test1="select CN_NAME from singers where singer_ID='2'";
     String test[]=songSearcher.doSelect(test1);
    %>
    <p><%=test[0]%>
</body>
</html>

the method that in the javabean is:
    public String[] doSelect(String selectString) throws SQLException{

        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

        // Connect to the database
                Connection conn =
            DriverManager.getConnection (dbDriver,dbUser, dbPwd);

        // Create a Statement
        Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

        ResultSet rset = stmt.executeQuery (selectString);
        int i=0;
        while (rset.next ())
            i++;
        String[] temp=new String[i];
        rset.beforeFirst();
        for(int j=0;j<i;j++){
            rset.next();
            temp[j]=rset.getString(1);

        }
        rset.close();
        stmt.close();
        conn.close();
        return temp;
    }




0
 
LVL 3

Accepted Solution

by:
Sendoh earned 150 total points
ID: 6344176
hi !!
think it is quite risky to return a string array from a functions...
actually u can try following code for ur bean :

public String doSelect(String selectString) throws SQLException{

       DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

       // Connect to the database
               Connection conn =
           DriverManager.getConnection (dbDriver,dbUser, dbPwd);

       // Create a Statement
       Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);

       ResultSet rset = stmt.executeQuery (selectString);
       int i=0;
       String retVal="";
       
       while (rset.next ())
       {
           if(i==0)
                   retVal = rset.getString(1);
              else
                   retVal += ";"+  rset.getString(1);
           i++;
        }
       rset.close();
       stmt.close();
       conn.close();
       return retVal;
   }


then following for ur jsp :

<%@ page language="java" import="ssei.*"%>
<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.util.*" %>

<HTML>
<HEAD>
<jsp:useBean id="Searcher" scope="request" class="ssei.sseiBean" >
   <jsp:setProperty name="Searcher" property="key_Word" param="key_Word"/>
   <jsp:setProperty name="Searcher" property="key" param="key"/>
</jsp:useBean>
<title>test</title>
<body>
   <%
    String test1="select CN_NAME from singers where singer_ID='2'";
    String test=songSearcher.doSelect(test1);
    StringTokenizer st = new StringTokenizer(test,";");
   
    while(st.hasMoreTokens())
    {
        %>
        <p><%=st.nextToken()%> <br>
       <%
     }
       %>
</body>
</html>

Hope it helps... :)

0
 

Author Comment

by:vivianQQ
ID: 6357985
Thank U.
It is caused by the string array!
but Y returning the string array can cause the problem?
0
 
LVL 3

Expert Comment

by:Sendoh
ID: 6358002
not sure what exactly was the problem...
but usually return an array from a function will cause problem....
think is due to the mem allocation problem cuz the array is actually localise...:P

regards Sendoh
0
 

Author Comment

by:vivianQQ
ID: 6358417
Thank U very much!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question