zheng yu

Greenhorn
+ Follow
since Apr 25, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by zheng yu

Thanks , you all
Here i give a interest situation i found :
There are 2 Japanese charactersets being often used here ( Shift_JIS & EUC_JP ). I find that if a String contains Zengaku characters( Zengaku means inner code is 2 bytes long , and occupy twice space as ASCII character ) only , IE will keep the column fixed and break the string automatically. But if my string contains ASCII character and Hangaku character ( means inner code is 2 byte long but occupy the same space as alphabetic , such as 'A'--'Z' , etc ) , it will be a disaster .
so now i wrote a function to scan the string that want to be displayed, convert every Hangaku character to Zengaku character. and it works fine
Thanks to Anjussha Nayyar, you answer my another question

i am so happy that i can always count on you guys
Regards
ZY
I have 1 servlet and 2 jsp fils(say a.jsp , b.jsp ) , one jsp( b.jsp) is embeded in the other jsp( a.jsp ) by using <IFRAME > Tag .
After servlet has finished its job ( save results as session variable ) , it use getRequestDispatch("a.jsp" ).forward(req,res ) to redirect the request to a.jsp . Does both a.jsp and b.jsp can access the same session variables ?
My situation is a.jsp can retrieve the session variable , b.jsp can access too , but it seems that data is corrupted ( In my situation , my session variable is a byte[] )
Thanks
ZY
22 years ago
TOMCAt3.2.1+Oracle8.1.7(classes12.zip) + JDK1.2.2
In my program , i use createStatement( TYPE_SCROLL_INSENSITIVE ,CONCUR_READ_ONLY ) to get scrollable resultset. And i use first() /last() /absolute() to implement my pager logic .
The problem is :
when i use getString(index) to get field data( defined as VARCHAR2) , what i get is its INNER CODE . for example :
for a field value like "1234" , what i get is "0x31323334"
Does some one face same problem like me ? does this problem has something to do with locale setting & charset ? My Locale is JP .
Thankx
ZY
Linux + TOMCAT3.2.1 + ORACLE8.1.7
I have a field named TITLECODE , i defined it as VARCHAR2 . And then insert some tuples into DB. their TITLECODE Field is like '00123456' .
When i use JDBC API to access TITLECODE field , what i get is like "0x3030313233343536". As all you can see , it give me its ASCII code
i want to get field value like '00123456', how can i do that ? Is there some DB configuration problem
Thanx in advance
ZY
22 years ago
I have a HTML table . It has 5 columns , and i specified that every column will occupy 20% space .When i add <TD> Tag , some of my data is too long , i want to keep column size fix and hope those long data can be seperated into multi-row text .
I want to know if HTML <TABLE > can do this
My code is like :
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=JISAutoDetect">
<META http-equiv="Pragma" content="No-cache">
<META http-equiv="Cache-Control" content="no-cache">
<META http-equiv="Expire" content="0">
<title></title>
<STYLE TYPE="text/css">
<!--
body,th,td { font-size:20px }
-->
</STYLE>
</head>
<body>
<div align="right">�����o�����������}�����������{���J�E���^�[���\�����������B</div>
<BR><%=strColumn[0] %><BR>
<BR><%=strTemp %><BR>
<%--
<BR><%=strOrg %><BR>
<BR><%=strReal %><BR>
--%>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="1" bgcolor="#FFCC99">
<TR>
<TD>
<TABLE width="100%" border="0" cellpadding="1" cellspacing="1">
<TR bgcolor="#FFFFFF">
<TD WIDTH="20%"><%=strColumn[0] %></TD>
<TD WIDTH="20%"><%=strColumn[1] %></TD>
<TD WIDTH="20%"><%=strColumn[2] %></TD>
<TD WIDTH="20%"><%=strColumn[3] %></TD>
<TD WIDTH="20%"><%=strColumn[4] %></TD>
</tr>
<%
if ( objResult != null ) {
for ( iLoop = 0 ; iLoop < iCount ; iLoop ++ ) {
objItem= ( SLSDMTL_K_Info )objResult.get(iLoop) ;
%>
<TR bgcolor="#FFFFFF">
<TD WIDTH="20%" ><%=objItem.m_LBNAME %></TD>
<TD WIDTH="20%" ><%=objItem.m_POSNAME %></TD>
<TD WIDTH="20%" ><%=objItem.m_DMDSIN %></TD>
<TD WIDTH="20%" ><%=objItem.m_BROWDV %></TD>
<TD WIDTH="20%" ><%=objItem.m_STNAME %></TD>
</tr>
<% }//end for
}//end if
%>
</TABLE>
</TD>
</TR>
</TABLE>
</body>
</html>

Help please
ZY
I have defined a class that contains lots of constants and common methods. I want all the servlet/JSP /Java program to share these constants and methods
This class is defined like this
public class Commondef{

17 static public final int ITEMS_PER_PAGE = 10 ;
18
19 static public final String SEARCHFLAG = "SearchFlag" ;
20 static public final String SEARCHSTRING= "SearchString" ;
21 static public final String CURRENTPAGE = "CurrentPage" ;
22 static public final String OPERATION = "Operation" ;
23 static public final String TITLECODE = "TitleCode" ;
24 static public final String DISPLAY = "Display" ;
25 static public final String PAGETOTAL = "PageTotal" ;
26 static public final String RECORDTOTAL = "RecordTotal" ;
...
58 static public byte getMaterialType( String strSearchFlag ) {
59 byte bType = 1 ;
60 if ( strSearchFlag != null ) {
61 if ( strSearchFlag.length() == 4 ) {
62 char chType = strSearchFlag.charAt(1) ;
63
.....

every time when i call getMaterialType method like :
byte bType = getMaterialType( strSearchFlag ) ;
tomcat give me an exception .
Can someone tell me if it is possible or not

ZY
22 years ago
I need to call self-defined class from jsp page .
my code is like this :
22 years ago
TOMCAT3.2.1 + Oracle 8i + JDK1.2.2
My program get some records from database , and want to show it in browser correctly .
Interesting thing is : in DB , some fields has value like "0015","0036" ,but after i read its value from database ands print it to TOMCAT'slog , it beccomes "0x30303135"
"0x30303336", see , it seems something like ASCII code.
I know i should use :
new String ( somestring.getBytes( charsetFrom ) , charsetTo )
to get correct string that i want to display
the questions is i dont know what the charsetFrom & charsetTo will be .
another question :
Does charsetFrom has something to do with Oracle Server's encoding setting ? if it does , how can i know Oracle Server's
current encoding setting , and how can i change it ?
Thanx in advance
ZY
22 years ago
Sorry
i dont know how to post code
ZY
22 years ago
Hi David
Your Trick worked . i am so happy ( because i have stuck up for 1,2 days 8-D )
My original design is :
Servlet :
.Execute specified SQL statement to get a resultset
.stuff all the tuples in that resultset into a LinkedList variable
.store this LinkedList object into HttpSession
JSP :
.get LinkedList variable from session
.traverse all the objects in that linkedlist and display its contents in client browser
My self-defined record structure is like this :
package search.common;
public class strucZassiKangouItem implements ijava.io.Serializable {
public StringstrKangou;public StringstrKiji;public StringstrTitleCode;
public strucZassiKangouItem() {
strKangou= null ;
strKiji= null;
strTitleCode= null;
}
}//:-
My servlet program is like this :
...
objBean.execSql() ;
// Set Session Variable
session.setAttribute( Commondef.SEARCHFLAG , strSearchFlag) ;
session.setAttribute( Commondef.SEARCHSTRING, strSearchString) ;
session.setAttribute( Commondef.CURRENTPAGE, String.valueOf(objBean.getPageCurrent())) ;
session.setAttribute( Commondef.OPERATION, strOperation) ;
session.setAttribute( Commondef.TITLECODE, strTitleCode) ;
session.setAttribute( Commondef.DISPLAY, objBean.getByteArray()) ;
....
getByteArray Function is like ( note Query result has been stored in lstResult ):
public byte[]getByteArray() {
byte[]bArray = null ;
try {
ByteArrayOutputStreambaos= new ByteArrayOutputStream();
ObjectOutputStreamoOut= new ObjectOutputStream( baos ) ;
oOut.writeObject( new Integer( lstResult.size()) ) ;
for ( int iLoop = 0 ; iLoop < lstResult.size() ; iLoop ++ ) {
oOut.writeObject( lstResult.get( iLoop )) ;
}//end for

oOut.flush();
bArray= baos.toByteArray() ;
oOut.close() ;
}catch ( IOException e ) {
baseServlet.Log("IoException occured in getOutputStream()") ;
}
return bArray ;
}
My JSP is like :
...
byte[]bArray= (byte[])session.getAttribute(Commondef.DISPLAY ) ;
ByteArrayInputStream bais= new ByteArrayInputStream( bArray ) ;
ObjectInputStream oIn= new ObjectInputStream( bais );
...
<TABLE width="896" border="0" cellpadding="0" cellspacing="0">
<%
int iLoop= 0;
for ( iLoop = 0 ; iLoop < objCount.intValue(); iLoop ++)
{
strucZassiKangouItemobjItem= ( strucZassiKangouItem )(oIn.readObject()) ;
String strKangou= "";
String strKiji= "";
String strTitle= "";
if ( objItem.strKangou != null )
strKangou= new String ( objItem.strKangou.getBytes() , "JISAutoDetect");
else
strKangou= "";
if ( objItem.strKiji != null )
strKiji= new String ( objItem.strKiji.getBytes() , "JISAutoDetect");
else
strKiji= "";
if ( objItem.strTitleCode != null )
strTitle= new String ( objItem.strTitleCode.getBytes() , "JISAutoDetect");
else
strTitle= "";
%>
<TR>
<TD width="490" height="88"><B><%=strKangou%></B>
<TABLE width="320" border="0">
<TR>
<TD><FONT size="2"><%=strKiji%></FONT></TD>
<TD align="right" valign="bottom"><FONT size="2"></FONT></TD>
</TR>
</TABLE>
</TD>
....
I think te problem is Classloader. i am using TOMCAT3.2.1.
It seems that tomcat use different classloader to load my servlet & jsp .Even i have verfied the object class name is the same by using Reflect API , there is always a ClassCastException thrown
thousands thanks again .
ZY
22 years ago
Can David show me some sample code to demo your little cool trick .
I think i am now running into such problems , hope you can help me out

Regards
ZY
22 years ago
TOMCAT3.2.1 + Linux + Oracle 8.1.7
I developed a servlet that store query result( a self-defined object ) in session , and use getRequestDispatcher().forward(..) to a JSP file . my problem is i always get ClassCastException.
can some body shed some light on it ?
My self-defined object is declared as follow
12 package search.db ;
13
14 public class strucZassiKangouItem extends Object{
15 public String strKangou ;
16 public String strKiji ;
17 public String strTitleCode;
18 public strucZassiKangouItem() {
19 strKangou = null ;
20 strKiji = null ;
21 strTitleCode= null ;
22 }
23 }//~:-
in my servlet program :
163 objRs.execSql() ;
164
....
169 // Set Session Variable
....
188 session.setAttribute( Commondef.DISPLAY, objRs.getLstResult()); // Store query result into session object
....
203 getServletContext().getRequestDispatcher("/jsp/ZassiKangou.jsp").forward(req, res);

my JSP is like this :
objResult = (LinkedList)session.getAttribute (Commondef.DISPLAY) ;
.....
everytime i use
strucZassiKangouItem objItem =( StrucZassiKangouItem )objResult.getFirst() ;
there is a ClassCastException .

i dont know why .
Thanks in advance
ZY

22 years ago
Now i am developing a B/S applications . Input device is touch panel only .
Boss ask me to make IE full screen . means that every time when user enter my html page , IE's titlebar/menubar /statusbar/...
should be killed or hided .
How can i do that ?
ZY
I have a text box in browser . Its Html code is like :
<INPUT type="text" name="textfield" size="80" MaxLength="40">
because the only input device is touch panel , so i create some keypads( Like japanese , english , chinese etc. )to simulate keyboard input .Javascript code is like
function keypress(txt) {
document.form1.textfield.value += txt ;
}
i have 2 question :
1 when i use keyboard , the text in that text field is autoscroll( you always can see what you input ) . But when i use my keypad , when text length exceed text box length , it doesnt scroll( without those arrow key or home/end ,you can not see the end of text ) . why and how can i make it autoscroll
2 Because i have set this text box's max length . when i use my keypad , it seems this max length does not take effect . Should i add some length control logic in my javascript function ?
Thanks in advance
ZY
Everntually , i have straighted it out .
Javascript function is like below :
function showKeyPad(keyPadType){
KeyPad.location.href = keyPadType + ".html" ;
}
Can some one show methe way to solve the 2nd question above
Thanks
ZY