Solved

Y the jsp put out the hex codes?

Posted on 2001-08-02
10
173 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
Industry Leaders: 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 50 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

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!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

726 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