How to write to log files using java files from JSP

Anybody knows different options in writing to log files using JSP?

Do you have an example?in the init() method of the servlet put the following
        FileOutputStream out = new FileOutputStream("your-log-file");
        PrintStream ps = new PrintStream(out);
        System.setOut(ps);
        System.setErr(ps);load the servlet on startup using <load-on-startup> in web.xml

Similar Messages

  • How to write a messenger with using java?

    May I know how to write a messenger with using java? The messenger need included two functions which are file transfer and add users to join the conversation.
    Thank you.

    Ok, so you need to start from the beginning, the requirements, is it a swing (i.e. GUI) app, web app, console, etc...?
    As stated by sprizor making an IM client is no easy task, you need to both implement the server side and the client side, which both communicate with each other, file transfers are also quite complex, and even maintaining a multi-user chat can be quite difficult.
    If you are after a Web Based app, then you will need to look into Push technologies, like Grizzly Comet which is a nice wrapper for the NIO java stuff:
    https://grizzly.dev.java.net/
    Good luck...

  • How to make bank management system using java file system

    Hi, I have some fields
    1.ID
    2. Deposite
    3. Withdraw
    4. Balance
    Now how can i manage this Bank Management System using java file system.
    Thanks in advance.

    Then we're back to (1): Do your own homework. Google has zillions of links on handling files in Java. When you have written some code and have an actual problem, we'll be happy to help you with it.
    (edit) Incidentally, this sounds suspiciously like the sort of problem they set for the certification programs. In which case, don't bother; they're not worth the virtual paper they're printed on.

  • How to write select statement directly in java file instead of using vo

    Hi,
    I have written the following code in my java file:
    if(empvo==null)
    empvo=worklistamimpl2.createViewObject("InvoiceVO", "xxetfc.oracle.apps.icx.icatalog.shopping.server.InvoiceVO");
    if(empvo!=null){
    OAViewObject oaviewobject2 = (OAViewObject)worklistamimpl2.findViewObject("InvoiceVO");
    OAViewObjectImpl oaviewobjectimpl = (OAViewObjectImpl)oapagecontext.getApplicationModule(oawebbean).findViewObject("InvoiceVO");
    oaviewobject2.setWhereClause("Invoice_num="+" ' " + s + " ' ");
    oaviewobjectimpl.executeQuery();
    String abc = (String)oaviewobjectimpl.first().getAttribute("Invoice_id");
    It is giving me error as
    oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (select invoice_id from ap_invoices_all) QRSLT WHERE (Invoice_num='ERS15022012_3')
    1. Why is this error coming.. how to solve this
    2. Instead of using vo how can i write select statement directly in the above code
    Thanks,
    Edited by: user10873676 on Apr 9, 2012 1:18 AM
    Edited by: user10873676 on Apr 9, 2012 1:21 AM

    it says java.sql.SQLSyntaxErrorException: ORA-00904: "INVOICE_NUM": invalid identifier
    where as invoice_num column is present in my table

  • How can I trasfer file using java program (from NT to Unix)

    Hi all,
    I want to transfer a text file from Windows NT to Unix machine inside the Java program.
    How should i do it.
    Thanks in advance.
    Regards
    Rajeev

    you have several options:
    - make your system administrator software install software on Unix and NT so that you can see a directory on the Unix machine from your NT machine, and just copy the file there
    - use FTP to put the file on the Unix machine
    Jesper

  • I Need help on how to write a simulation program using Java

    I am currently working on my final project and i will be grateful if i can get any help on the needed resources that i will require for my code

    Benny,
    If that means you want someone to work for you, then you better have deep pockets, most of the developers' time goes for 100+ an hour.
    But if you mean you would like to ask quesitons about code you have written and get advice on how to continue or fix a problem you are having, then post the relavant code piece and ask away. There are many that will be glad to help you in that manner.
    But this is NOT a do my homework for me board and unless you can clue your Prof in that your work is not your own, then you would be cheating for a grade you do not deserve, and in that case--please just go else where or drop out--either one will make no difference to me or most of the developers on this board.

  • Using java class from JSP page

    I have a class that connects to the database and return the result in form of array of objects, now I wrote a tester and I was able to print the result on the console but when it came to JSP how can I use this class I am a bit confused, how can I declare an array of objects and save the result that comes from the class method
    note: my class is not a bean it is a service class that contain methods to retreive different information from the database.
    I would apritiate any help but please make it in sequence for example declaring an array to hold the result then call the method that returns the array of objects..etc
    please help, I am really confused and don't know what to write
    thank you

    You can access a class in the same way as a bean, after all a bean is just a class that follows a set of rules.
    You need to put your classes in packages to access them.
    I have 2 packages, params and DTO. I set the class that returns the Data Transfer Object, or array of objects up as I would a bean
    <jsp:useBean id="DTO" scope="request" class="params.DTO" />
    I think you skip the above declaration and access it directly in code using
    params.DTO();
    but setting it up as I would a bean allows me to simply use
    DTO();
    DTO is the class that passes back the array of objects.
    Objects themselves I have in a seperate package, also called DTO (sorry if this is confusing, made sense at the time :-) ) You dont need them in seperate packages, just helped me keep DTO objects seperate from business logic classes......
    Now before I use params.DTO() I declare a variable of the Object type DTO() returns
    <%! DTO.workSheet[] ws; %>
    So, ws is the object type that will be returned by params.DTO()
    Then to get my array of objects back from params.DTO() :-
    ws = DTO.workSheet(day);
    or if you dont like the bean declaration
    ws = params.DTO.workSheet(day);
    You need to put your packages under WEB-INF/Classes when using Tomcat
    So I have
    Tomcat 5.0\webapps\myApplication\WEB-INF\classes\params
    Tomcat 5.0\webapps\myApplication\WEB-INF\classes\DTO
    Under which reside the classes

  • How to Write in bold to a file using java I/O classes?

    Hi,
    Using I/O classes I want to prepare a .doc file in which some text will be there. I want that text to be formatted. Like some text I want to be bold. Some text to be italic. How can I write bold/Italic text to the file using java I/O classes.
    Thanks
    Prashant

    By .doc file, I'm assuming you mean an MS Word document, yes? (fyi, Word Perfect also used the .doc extension)
    The .doc format is proprietary to Microsoft and isn't documented by them. In order to output a file in .doc format you'd have to understand that format correctly, otherwise MS Word will spit out it's tongue at you, call you names, and maybe send the Microsoft Police to "audit" your PC Software Licensing.
    Fortunately for you there is an open source project to demangle the microsoft file formats. See http://jakarta.apache.org/poi/ and especially pay attention to the HDF project (Horrible Document Format).
    - David

  • How to write as XML file using java 1.5

    hi all,
    i am trying to create an XML file using java 1.5. I took a XML creating java file which was working with java 1.4 and ported same file into java 1.5 with changes according to the SAX and DOM implmentation in java 1.5 and tried to compile. But while writing as a file it throws error "cannot find the symbol."
    can any body help me out to solve this issue.......
    thankx in advance
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.NamedNodeMap;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.DocumentHandler;
    import org.xml.sax.InputSource;
    import org.xml.sax.helpers.ParserFactory;
    import java.io.*;
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();                   
                   dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();                   
    Document xmlDoc =  db.newDocument();
    // this creates the xml document ref
    // parent node reference
    Element rootnd = (Element) xmlDoc.createElement("ALL_TABLES");
    // root node
    xmlDoc.appendChild(rootnd);
    Element rownd = (Element) xmlDoc.createElement("ROW");
    rootnd.appendChild(rownd);
    Element statusnd = (Element) xmlDoc.createElement("FILE_STATUS");
    rownd.appendChild(statusnd);
    statusnd.appendChild(xmlDoc.createTextNode("Y")
    FileOutputStream outpt = new FileOutputStream(outdir + "//forbranch.xml");
    Writer outf = new OutputStreamWriter(outpt, "UTF-8");
    //error is occuring here Since write method is not available in the Document class
    xmlDoc.write(outf);
    outf.flush();

    Hi,
    when I look in the JDK1.4.2 specification I don't see any write method in the Document interface.
    However, your solution is the Transformer class. There you transform your DOM tree into any output you need. Your code sould look something like this:     TransformerFactory tf = TransformerFactory.newInstance();
         // set all necessary features for your transformer -> see OutputKeys
         Transformer t = tf.newTransformer();
         t.transform(new DOMSource(xmlDoc), new StreamResult(file));Then you have your XML file stored in the file system.
    Hope it helps.

  • How to Write data in Excel File using java

    Hi
    can anybody help me to write data in excel file
    using java code
    Thankx In Advance

    How much are you willing to pay for that?
    If you want it for free, http://jexcelapi.sourceforge.net/

  • How to read pdf files using java.io package classes

    Dear All,
    I have a certain requirement that i should read and write PDF files at runtime. With normal java file IO reading is not working. Can any one suggest me how to proceed probably with sample code block
    Thanks in advance.

    hi I also have the pbm. to read pdf file using JAVA
    can any body help meWhy is it so difficult to read the thread you posted in? They say: java.io is pointless, use iText. So why don't you?
    or also I want to read a binary encoded data into
    ascii,
    can anybody give me a hint how to do it.Depends on what you mean with "binary encoding". ASCII's binary encoding, too, basically.

  • How to print a text file using Java

    How can I print a text file using Java without converting the output to an image format. Is there anyway I can send the characters in the text file as it is for a print job? I did get a listing doing this ... but that converted the text to an image format before printing....
    THanks,.

    Hi I had to write a print api from scratch, and I did not convert the output to image. Go and read up on the following code. I know there is a Tutorial on Sun about the differant sections of the snippet.
    private void printReport()
         Frame tempFrame = new Frame(getName());
         PrintJob printerJob = Toolkit.getDefaultToolkit().getPrintJob(tempFrame, "Liesltext", null);
         Graphics g = printerJob.getGraphics();
                    //I wrote the method below for calculations
         printBasics(g);
         g.dispose();
         printerJob.end();
    }This alone wont print it you have to do all the calculations in the printBasics method. And as I said I wrote this from scratch and all I did was research first the tutorial and the white papers
    Ciao

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

  • How to format a excel file use java.

    hi,
    everyone, i meet a problem.i want to write a excel file use java.i can use .csv input the date to excel.but i want to know how to format it.
    thanks
    Jove

    hi,
    everyone, i meet a problem.i want to write a excel
    el file use java.i can use .csv input the date to
    excel.but i want to know how to format it.
    thanks
    JoveIf I understand your question correctly you need to know the format of a .csv file for use in an Excel spreadsheet. A .csv file is a comma-delimited file so all that you need to do is write your data elements to the file with commas in between them. Having done something similar in the past, let me warn you that when Excel is reading your file, it uses some characters other than commas as field delimiters. for example, / : and ; are treated as commas. To defeat this, you will need to surround fields containing those characters in double quotes.
    Hope that helps
    Mark

  • How to create and edit a .ini file using java

    Hi All...
    Pls help me in creating and editing an .ini file using java...
    thanks in advance
    Regards,
    sathya

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

Maybe you are looking for