I changed these two line to get it to work from my nokia.

*<%@ page contentType="text/vnd.wap.wml"%>*

* String ss1=new String(readbyte).substring(0,charcount);*

Need to print only the charaters read into the buffer.

You will get an error if the file is zero length so you could do a test 
before String ss
E.G.
* if (charcount == -1) charcount=0;
 String ss1=new String(readbyte).substring(0,charcount);
*


You could also do other test on length of the file with

File infile=new File("C:/TextFiles/" + filename + ".txt");
long strLen =  infile.length();

Regards,
Simon



Galbayar wrote:

>my jsp is: I can't find any error. but WAP browser have Page Cannot be
>displayed error.
>
><%@ page contentType="text/vnd.wap.wml;charset=ISO-8859-1"%>
><%response.setHeader("Cache-Control","no-cache");%>
><%@ page import="java.io.*"%>
><?xml version="1.0"?>
><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
>"http://www.wapforum.org/DTD/wml_1.1.xml";>
>
><wml>
><card id="main" title="is">
><p>
><%
> String pagenum=request.getParameter("page");
> String filename=request.getParameter("f");
> if (pagenum==null) pagenum="1";
> int skipbyte=500;
>  byte[] readbyte=new byte[skipbyte];
>  boolean isEnd=false;
>  try
>  {
>   FileInputStream in=new
>FileInputStream("C:\\TextFiles\\"+filename+".txt");
>   in.skip(skipbyte*(Integer.parseInt(pagenum)-1));
>   int charcount=in.read(readbyte);
>   if (charcount<skipbyte) isEnd=true;
>   in.close();
>   String ss1=new String(readbyte);
>    out.println(ss1);
>   out.flush();
>  }
>  catch(FileNotFoundException e)
>  {
>       out.println("File Not Found");
>  }
>  catch(IOException e)
>  {
>       out.println("IO error");
>  }
>%>
><%
> String linkstr="";
>
>linkstr=(isEnd)?Integer.toString(Integer.parseInt(pagenum)-1):Integer.toStri
>ng(Integer.parseInt(pagenum)+1);
>%>
> </p>
> <p>
> <a
>href="ReadFileWml.jsp?page=<%=linkstr%>&amp;f=<%=filename%>"><%=(isEnd)?"Bac
>k":"Next"%></a></p>
><p>
><do type="prev" label="back"><prev/></do>
></p>
></card>
></wml>
>
>
>--
>To unsubscribe:   <mailto:[EMAIL PROTECTED]>
>For additional commands: <mailto:[EMAIL PROTECTED]>
>Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>




--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to