Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Just reading log file and display the content in a text area.

One browse component to get the server log file and a text area.

It should run in any web application server

Plz help me about the coding.

I developed two jsp file.

that is

101.jsp
........
XML
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Upload Page</title>
</head>
<body>
<form name="form1" id="form1" action="101.jsp" method="post" enctype="multipart/form-data">
<input type="hidden" name="hiddenfield1" value="ok">
Files to upload:
<br/>
<input type="file" size="50" name="file3">
<br/>
<input type="submit" value="Upload">
</form>
</body>
</html>


and
101.jsp
........
XML
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.io.File" %>
<%@ page import="java.io.IOException"%>
<%@ page import="java.io.PrintWriter"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="java.io.*, java.net.*" %>

<%
response.setContentType("text/html");
         /*PrintWriter out = response.getWriter();*/

boolean isMultipartContent = ServletFileUpload
.isMultipartContent(request);
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
try {

List<FileItem> fields = upload.parseRequest(request);
Iterator<FileItem> it = fields.iterator();

while (it.hasNext()) {
FileItem fileItem = it.next();
byte[] bb=fileItem.get();
ByteArrayInputStream bais=new ByteArrayInputStream(bb);
BufferedReader br = new BufferedReader((new InputStreamReader(bais)));
//out.println(br);
String data;
while((data= br.readLine())!= null)
{
out.println(data);
//out.write(data);
}
br.close();
  }

}
catch (FileUploadException e) {
e.printStackTrace();
}
%>
just tell me how i displays the contents of the log file in the text area in the same page.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900