Solved

Y the jsp put out the hex codes?

Posted on 2001-08-02
10
168 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 68
topping3 challenge 14 69
java. non-English characters encoding problem. intellij idea 3 73
split string containing \r\n in Java 46 38
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now