Common method of reading text files, and wrap method in JSP

sponsored links
JAVA in:
package com.action;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.connSql.DAOException;
import com.form.MonitorViewForm;

public class ReadTxtAction extends Action (

public ActionForward execute (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws DAOException (

MonitorViewForm lf = (MonitorViewForm) form;

System.out.println ("ReadTxtAction");
String findForward = "";
/ **
* Read txt data
* /

String url = "D: / mbfe.log";

lf.setMefe (this.ReadDate (url));

findForward = "sucess";

return mapping.findForward (findForward);

/ **
* Read txt data
* /
public String ReadDate (String url) (
try (
FileReader read = new FileReader (new File (url));
StringBuffer sb = new StringBuffer ();
char ch [] = new char [1024];
int d = (ch);
while (d! =- 1) (
String str = new String (ch, 0, d);
sb.append (str);
d = (ch);
System.out.print (sb.toString ());
read.close ();
return sb.toString (). trim ();
) Catch (FileNotFoundException e) (
/ / E.printStackTrace ();
return null;
) Catch (IOException e) (
/ / E.printStackTrace ();
return null;


JSP in:
<pre> <bean:write name="monitorViewForm" property="mefe" /> </ pre>
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of Common method of reading text files, and wrap method in JSP

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • First Hibernate Example

    Curd a simple example. Source does not contain the dependent libraries, or playing too much of the package. PO object Note: One must have the default constructor 2 non-final modified. Otherwise useless lazy loading. UserDAOImpl category code, and other co

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent Entries
Tag Cloud
Random Entries