Creating a File in JSP

Dear Friends,
My jsp file is resides on D:\Kinjal\k.jsp
In Jsp file i had written
File f =new File("kinjal.txt");
Then it will create or refer file kinjal.txt in my D:\ instead of Current working directory (D:\Kinjal).
In Java it will create in current directory when our java code resides. Then please tell me why in JSP it is not created in current working Directory.
If u have any doubts/query and suggestion regarding it then mail me
[email protected]

Use this code
import java.io.*;
File file = new File(path,fName);
boolean cr = file.createNewFile();
test if cr= true i e file created
if cr= false than not created..
path is path where u want file to put
fName=name of file for example "urfile.txt"
hope it helps
njoy
regds

Similar Messages

  • Need to create PAR files from JSP

    Hi,
    In my project we are creating portal archives from JSP iviews .
    Using NWDS we can easily create par files by going to Enterprise Portal workspace  .But in my project we are not using NWDS or any other JSP editor .
    Can anybody tell me how to create par files if i am using only notepad to develop my JSP .
    Thanks a lot .

    Hi
    here is the link how to create a par file without using any editor
    http://support.sas.com/rnd/itech/doc9/portal_dev/tasks/dg_portlet_parfile.html
    all the best..
    thanks Regards ,
    Boopalan.M

  • Excel size becomes large while creating excel file in jsp using content typ

    Hi All,
    I created an excel using jsp by setting content type as excel, the size of the excel is coming nearly around 5MB. If copy the content of that 5MB excel content and paste it and created another excel directly. The size of the new excel is coming around 1 MB.
    It will be great if any body reply me as soon as possible.

    HBhagya wrote:
    I created an excel using jsp by setting content type as excelYou don't create an Excel file that way. You're just fooling the web browser that it is an Excel file so that it will try to use the associated application for that which on its turn is too forgiving that it accepts HTML.
    Look for a Java Excel API to create a real Excel file. Examples: Apache POI HSSF, JExcelAPI, OpenXML4J. Or just use the CSV file format, although you can write it yourself easily, there are API's out as well. Examples: CSV4J, JavaCSV, OpenCSV.

  • Plz...  How to Create .war file in tomcat 5.0

    plz...
    i want clear steps to create .war file
    for jsp or servlet in tomcat 5.0.
    yours
    vijay

    Here is the sample script, U can use this script to build war file:
    Change the following before running the script:
    WebAppDir path to the Tomcat webapps directory
    AppsName value to ur Project Name ie Ajax to diff name.
    basedir - Give webapps dir of ur src files.
    <project default="build" basedir=".">
    <target name="build">
    <tstamp/>
         <property name="WebAppsDir" value="c:\Tomcat\webapps"/>
    <property name="AppsName" value="Ajax"/>
         <delete dir="${WebAppsDir}\${AppsName}"/>
    <delete file="${WebAppsDir}\${AppsName}.war"/>
    <jar jarfile="${WebAppsDir}/${AppsName}.war"
              basedir="D:\eclipse\AjaxEx\webapps"
    includes="**" />
    </target>
    </project>
    Once you run this file. It will create war file in the webapps dir of ur tomcat.
    Bye,
    Vinay

  • Creating a file download link on jsp

    I have the following on my jsp. The code worked fine until I tried to use it in a new html design page.
    <code>
    //page name is index.jsp
    try //DISPLAY THE CONTENTS OF THE DATA DIRECTORY
    File dirname = new File(PATH); // create an instance of the File class
    if (dirname.exists()&&dirname.isDirectory())//check to see if File class dirname exists and is valid
    String [] allfiles = dirname.list();//create an array of files in the dirname File class
              for (int i=0; i< allfiles.length; i+=2)//loop through allfiles[] and print out file links
    out.println("<br><table border='1' cellspacing='1' width='99%'>");
                   out.println("<tr><td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i]+"'>"+allfiles[i]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td>
    <% if(i+1 < allfiles.length)//PRINTS OUT THE SECOND TD SO THAT WE HAVE 2 COLUMNS OF LINKS
    out.println("<td width='50%' class='pageFont'><input type='checkbox' name='cb' value='"+allfiles[i+1]+"'>"+allfiles[i+1]+"      ");
    %>
    <a class="a" href="index.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a></td></tr>
    <%
    out.println("</form></font></table>");
    catch (IOException excep)
         out.println("An IO exception has occured.");
    </code>
    Then when clicked this code is run:
    <code>
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
    if (request.getParameter("downfile") != null)
    String filePath = request.getParameter("downfile");
    File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
    if (f.exists() && f.canRead())
    response.setContentType ("application/octet-stream");
    response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
    response.setContentLength((int) f.length());
    BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
    int i;
    out.clearBuffer();
    while ((i = fileInputStream.read()) != -1) out.write(i);
    fileInputStream.close();
    out.flush();
    </code>
    When I click on this link I get the download dialog box. If I open it I get the following open up in notepad(the files I am trying to give download links are .txt files)
    Below is what is displayed in notepad ALL on 1 line:
    <html>
    <head>
    <LINK rel="stylesheet" ty
    That is displayed in all of the links that I click on. It is the first few lines of html code for index.jsp.
    I know this code is probably not a good way of doing what I need but I got it to work fine until the change.
    I am sure there is an easier way to code the download link without resubmitting the page.
    Thanks in advance!!

    Well all was fine with this jsp until I moved it to ApacheJServ. Now the problem has resurfaced(although it is a little different now)
    I had moved the following code to the top of my page:
    //CHECK TO SEE IF EITHER DOWNFILE OR ZIPFILE VARIABLE EXIST, AND IF THEY DO SET CONTENT TYPE BEFORE SENDING ANY HTML CODE TO THE BROWSER
    try{
    //CHECK TO SEE IF THE FILE HAS BEEN CLICKED TO DOWNLOAD SINGLE FILE
        if (request.getParameter("downfile") != null)
                String filePath = request.getParameter("downfile");
                File f = new File(filePath);//CREATE AN INSTANCE OF THE FILE CLASS AND POINT IT TO THE LOCATION OF THE DIRECTORY CONTAINING THE FILES
                    if (f.exists() && f.canRead())
                        response.setContentType ("application/octet-stream");
                        response.setHeader ("Content-Disposition", "attachment;filename=\""+f.getName()+"\"");
                        response.setContentLength((int) f.length());
                        BufferedInputStream fileInputStream = new BufferedInputStream(new FileInputStream(f));
                        int i;
                        out.clearBuffer();
                        while ((i = fileInputStream.read()) != -1) out.write(i);
                            fileInputStream.close();
                            out.flush();
                            response.flushBuffer();
    catch (Exception e){}
    //This is where the java code ends and the javascript/html code begins.Then further into the page I create the file download links like so:
                            <a class="a" href="main.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a>I know this isnt a secure way of doing this but I am on a intranet.
    The problem I am having now is that when I click on one of the links and download the file and then open it, I get the contents of the file plus concatenated to the end of it is the first few HTML lines of the actual jsp that I downloaded the file from. Before I was just getting the first few lines of html from the jsp, not the actual contents of the downloaded file.
    This is an example of what I am getting:
    This is the contents of the file that I downloaded.//This is where the file contents ends.
    <html>
    <head>
    <LINK rel="stylesheet" type="text/css" href="default.css">
    <script language="JavaScript1.2">
    //function that allows user to select all checkboxes
    function doIt(v)
    for(var i=0;i<document.form1.cb.length;i++)
       document.form1.cb.checked=eval(v);
    function swap(imageName,image)
    imageName.src = "templateImages/"+image;
    function imageOver(imageSrc, imageName)
         changeImage = new Image();
         changeImage.src = imageSrc;
         document.images[imageName].src = changeImage.src;
    var hide = true;
    function hideShow( ) /
    Any morre ideas?
    TIA!
    BTW, I went to ApacheJServ because they wont let me use tomcat :(

  • Creating a File object in a JSP page

    Hi,
    I am trying to create a File object in my JSP page by passing it a relative path. The jsp page is in 'website/testfolder/index.jsp' and the File is in 'website/photos/1.jpg'. In my jsp page i do the following:
    <% File f = new File("../photos/1.jpg");
    boolean test = f.isFile(); %>
    The value returned is false. I am trying to figure out why it can't locate the file.
    Thanks

    You have to use absolute paths. You can get the absolute path for the given relative path by ServletContext#getRealPath().

  • Automatic created Java file error when compile JSP file

    I got the following error message when i try to load the JSP file given below (FlightSearch.jsp). Given also below the JAVA files (flightsearch$jsp.java) created by the compiler.
    Thanks for your help
    Susan
    Error message
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:320: 'catch' without 'try'.
    } catch (Throwable t) {
    ^
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:328: 'try' without 'catch' or 'finally'.
    ^
    C:\jakarta-tomcat\work\client\localhost\client\client\flightsearch$jsp.java:328: '}' expected.
    ^
    3 errors, 1 warning
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
    at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
    at java.lang.Thread.run(Thread.java:536)
    FlightSearch.jsp
    <%@page import="java.util.*" errorPage="ErrorHandler.jsp"%>
    <%@page import="com.client.entity.Flight"%>
    <%@page import="com.client.wsclient.FlightServiceClient"%>
    <H3>Available Flight List</H3>
    <br>We have found the following Available flight(s) : </br>
    <table border="0" cellpadding="0" cellspacing="0" width="100">
    <tr>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Flight Company</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Flight Number</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Depart From<font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrive</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Departure Date</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Departure Time</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrival Date</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Arrival Time</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Adult Fare</font></b></td>
    <td width="10%" bgcolor="#808080"><b><font color="#FFFFFF">Child Fare</font></b></td>
    </tr>
    <%
    //Get the search information
    String des = request.getParameter("DFrom");
    String arr = request.getParameter("DTo");
    String fy = request.getParameter(FYear.value);
    String fm = request.getParameter(FMonth.value);
    String fd = request.getParameter(FDay.value);
    String f1 = fy + "-" + fm;
    String FDat = f1 + "-" + fd;
    String ty = request.getParameter(TYear.value);
    String tm = request.getParameter(TMonth.value);
    String td = request.getParameter(TDay.value);
    String t1 = ty + "-" + tm;
    String TDat = t1 + "-" + td;
    String type;
    if( request.getParameter(type[0].checked))
    type = "Return";
    else
    { type = "OneWay";
    String clas;
    if(request.getParameter(clas[0].checked))
    {clas = "ECO";
    else
    {clas = "BUSS";}
    String adult = request.getParameter(Adult.value);
    String child = request.getParameter(Child.value);
    //Get the server Flight Search Service URL
    // ServerFlightSearchBO SFSBO = new ServerFlightSearchBO();
    // ServerFlightSearch FlightSearch = SFSBO.getFlightSearchURL();
    // FlightSearchServiceClient FSearchServiceClient = new FlightSearchServiceClient
    String ServerFlightServiceURL = "http://localhost:7080/AServer/services/FlightService";
    //Find available Flight
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(des, arr, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    %>
    <tr>
    <td width= "10%"><%=flt.getFlightComp()%></td>
    <td width= "10%"><%=flt.getFlightNum()%></td>
    <td width= "10%"><%=flt.getDestination()%></td>
    <td width= "10%"><%=flt.getArrive()%></td>
    <td width= "10%"><%=flt.getFrDate()%></td>
    <td width= "10%"><%=flt.getFlightDptTm()%></td>
    <td width= "10%"><%=flt.getToDate()%></td>
    <td width= "10%"><%=flt.getFlightArrTm()%></td>
    <%
    int adt, chld;
    int far_A, tot_A, far_C, tot_C;
    adt = Integer.parseInt(adult);
    far_A = flt.getAdultFr();
    tot_A = adt * far_A;
    chld = Integer.parseInt(child);
    far_C = flt.getChildFr();
    tot_C = chld * far_C;
    %>
    <td width= "10%"><%=tot_A%></td>
    <td width= "10%"><%=tot_C%></td>
    </tr>
    <%
    if(type = "Return")
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(arr, des, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    %>
    <tr>
    <td width= "10%"><%=flt.getFlightComp()%></td>
    <td width= "10%"><%=flt.getFlightNum()%></td>
    <td width= "10%"><%=flt.getFlightDpt()%></td>
    <td width= "10%"><%=flt.getFlightArr()%></td>
    <td width= "10%"><%=flt.getFlightDptDt()%></td>
    <td width= "10%"><%=flt.getFlightDptTm()%></td>
    <td width= "10%"><%=flt.getFlightArrDt()%></td>
    <td width= "10%"><%=flt.getFlightArrTm()%></td>
    <%
    int adlt, chd;
    int fare_A, totA, fare_C, totC;
    adlt = Integer.parseInt(adult);
    fare_A = flt.getAdultFr();
    totA = adlt * fare_A;
    chd = Integer.parseInt(child);
    fare_C = flt.getChildFr();
    totC = chd * fare_C;
    %>
    <td width= "10%"><%=totA%></td>
    <td width= "10%"><%=totC%></td>
    </tr>
    <%
    %>
    </table>
    flightsearch$jsp.java
    package org.apache.jsp;
    import java.util.*;
    import com.client.entity.Flight;
    import com.client.wsclient.FlightServiceClient;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import org.apache.jasper.runtime.*;
    public class flightsearch$jsp extends HttpJspBase {
    static {
    public flightsearch$jsp( ) {
    private static boolean jspxinited = false;
    public final void jspxinit() throws org.apache.jasper.runtime.JspException {
    public void _jspService(HttpServletRequest request, HttpServletResponse response)
    throws java.io.IOException, ServletException {
    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    String _value = null;
    try {
    if (_jspx_inited == false) {
    synchronized (this) {
    if (_jspx_inited == false) {
    jspxinit();
    jspxinited = true;
    _jspxFactory = JspFactory.getDefaultFactory();
    response.setContentType("text/html;ISO-8859-1");
    pageContext = _jspxFactory.getPageContext(this, request, response,
    "ErrorHandler.jsp", true, 8192, true);
    application = pageContext.getServletContext();
    config = pageContext.getServletConfig();
    session = pageContext.getSession();
    out = pageContext.getOut();
    // HTML // begin [file="/client/flightsearch.jsp";from=(0,59);to=(1,0)]
    out.write("\r\n");
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(1,43);to=(2,0)]
    out.write("\r\n");
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(2,58);to=(19,0)]
    out.write("\r\n\r\n<H3>Available Flight List</H3>\r\n<br>We have found the following Available flight(s) : </br>\r\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100\">\r\n <tr>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Flight Company</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Flight Number</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Depart From<font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrive</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Departure Date</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Departure Time</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrival Date</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Arrival Time</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Adult Fare</font></b></td>\r\n <td width=\"10%\" bgcolor=\"#808080\"><b><font color=\"#FFFFFF\">Child Fare</font></b></td>\r\n </tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(19,2);to=(66,0)]
    //Get the search information
    String des = request.getParameter("DFrom");
    String arr = request.getParameter("DTo");
    String fy = request.getParameter(FYear.value);
    String fm = request.getParameter(FMonth.value);
    String fd = request.getParameter(FDay.value);
    String f1 = fy + "-" + fm;
    String FDat = f1 + "-" + fd;
    String ty = request.getParameter(TYear.value);
    String tm = request.getParameter(TMonth.value);
    String td = request.getParameter(TDay.value);
    String t1 = ty + "-" + tm;
    String TDat = t1 + "-" + td;
    String type;
    if( request.getParameter(type[0].checked))
    type = "Return";
    else
    { type = "OneWay";
    String clas;
    if(request.getParameter(clas[0].checked))
    {clas = "ECO";
    else
    {clas = "BUSS";}
    String adult = request.getParameter(Adult.value);
    String child = request.getParameter(Child.value);
    //Get the server Flight Search Service URL
    // ServerFlightSearchBO SFSBO = new ServerFlightSearchBO();
    // ServerFlightSearch FlightSearch = SFSBO.getFlightSearchURL();
    // FlightSearchServiceClient FSearchServiceClient = new FlightSearchServiceClient
    String ServerFlightServiceURL = "http://localhost:7080/AServer/services/FlightService";
    //Find available Flight
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(des, arr, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(66,2);to=(68,18)]
    out.write("\r\n<tr>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(68,21);to=(68,40)]
    out.print(flt.getFlightComp());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(68,42);to=(69,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(69,21);to=(69,39)]
    out.print(flt.getFlightNum());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(69,41);to=(70,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(70,21);to=(70,41)]
    out.print(flt.getDestination());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(70,43);to=(71,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(71,21);to=(71,36)]
    out.print(flt.getArrive());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(71,38);to=(72,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(72,21);to=(72,36)]
    out.print(flt.getFrDate());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(72,38);to=(73,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(73,21);to=(73,41)]
    out.print(flt.getFlightDptTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(73,43);to=(74,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(74,21);to=(74,36)]
    out.print(flt.getToDate());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(74,38);to=(75,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(75,21);to=(75,41)]
    out.print(flt.getFlightArrTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(75,43);to=(76,1)]
    out.write("</td>\r\n ");
    // end
    // begin [file="/client/flightsearch.jsp";from=(76,3);to=(87,1)]
    int adt, chld;
    int far_A, tot_A, far_C, tot_C;
    adt = Integer.parseInt(adult);
    far_A = flt.getAdultFr();
    tot_A = adt * far_A;
    chld = Integer.parseInt(child);
    far_C = flt.getChildFr();
    tot_C = chld * far_C;
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(87,3);to=(88,18)]
    out.write("\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(88,21);to=(88,26)]
    out.print(tot_A);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(88,28);to=(89,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(89,21);to=(89,26)]
    out.print(tot_C);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(89,28);to=(91,0)]
    out.write("</td>\r\n</tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(91,2);to=(100,0)]
    if(type = "Return")
    FlightServiceClient client = new FlightServiceClient(ServerFlightServiceURL);
    ArrayList list = client.getFlight(arr, des, FDat, TDat, type, clas, adult, child);
    Iterator it = list.iterator();
    while (it.hasNext()){
    Flight flt = (Flight)it.next();
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(100,2);to=(102,18)]
    out.write("\r\n<tr>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(102,21);to=(102,40)]
    out.print(flt.getFlightComp());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(102,42);to=(103,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(103,21);to=(103,39)]
    out.print(flt.getFlightNum());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(103,41);to=(104,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(104,21);to=(104,39)]
    out.print(flt.getFlightDpt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(104,41);to=(105,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(105,21);to=(105,39)]
    out.print(flt.getFlightArr());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(105,41);to=(106,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(106,21);to=(106,41)]
    out.print(flt.getFlightDptDt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(106,43);to=(107,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(107,21);to=(107,41)]
    out.print(flt.getFlightDptTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(107,43);to=(108,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(108,21);to=(108,41)]
    out.print(flt.getFlightArrDt());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(108,43);to=(109,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(109,21);to=(109,41)]
    out.print(flt.getFlightArrTm());
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(109,43);to=(110,1)]
    out.write("</td>\r\n ");
    // end
    // begin [file="/client/flightsearch.jsp";from=(110,3);to=(120,1)]
    int adlt, chd;
    int fare_A, totA, fare_C, totC;
    adlt = Integer.parseInt(adult);
    fare_A = flt.getAdultFr();
    totA = adlt * fare_A;
    chd = Integer.parseInt(child);
    fare_C = flt.getChildFr();
    totC = chd * fare_C;
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(120,3);to=(121,18)]
    out.write("\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(121,21);to=(121,25)]
    out.print(totA);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(121,27);to=(122,18)]
    out.write("</td>\r\n <td width= \"10%\">");
    // end
    // begin [file="/client/flightsearch.jsp";from=(122,21);to=(122,25)]
    out.print(totC);
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(122,27);to=(124,0)]
    out.write("</td>\r\n</tr>\r\n");
    // end
    // begin [file="/client/flightsearch.jsp";from=(124,2);to=(126,0)]
    // end
    // HTML // begin [file="/client/flightsearch.jsp";from=(126,2);to=(127,8)]
    out.write("\r\n</table>");
    // end
    } catch (Throwable t) {
    if (out != null && out.getBufferSize() != 0)
    out.clearBuffer();
    if (pageContext != null) pageContext.handlePageException(t);
    } finally {
    if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);

    i am very glad and appreciate for your help, but i would like to know how to get the value of a radio button.
    like in another JSP file i have :
    <input type="radio" name="type" value="Return" checked>
    Return
    <input type="radio" name="type" value="OneWay">
    One Way
    and when i try to get the value which is checked, i put
    String type = request.getParameter(type.checked);
    but this doesn't work,
    i would be very appreciate for your help. Thank you

  • How to create a directory for JSPs under infrastructure "root"?

    Hi,
    I'm not very familiar with Oracle 10gAS, but someone else got it configured and running on a Solaris 9 system, so my terminology may not be correct...
    We now have an "infrastructure" website (at port 7777) and an "ias" website (at port 8000).
    Right now, under the "infrastructure" website, we have the following applications:
    - sso
    - oiddas
    These all are "under" an OC4J instance called "OC4J_SECURITY".
    I need to somehow configure things so that I have a directory directly under the "root" of the "infrastructure" website (e.g., at http://<host>:7777/myjspdirectory) where I can run some JSPs. For example, I want to be able to put a JSP named "foo.jsp" and be able to access it at http://<host>:7777/myjspdirectory/foo.jsp.
    Is there a SIMPLE way to do this? If there is, can someone provide the specific steps (e.g., which directories, and files I need to create/modify)?
    It's not a "full" web application, so I don't want to have to create a WAR, etc.
    So far, I think that I need to add some "MountOc4j" lines to the mod_oc4j.conf file:
    Oc4jMount /myjspdirectory OC4J_SECURITY
    Oc4jMount /myjspdirectory/* OC4J_SECURITY
    But, after that I'm kind of lost :(...
    Is the only way to create a full WAR and then try to deploy it?
    Sorry if my question is somewhat confused, but I guess I am :(...
    Thanks in advance,
    Jim

    qlin,
    Ok, thanks.
    I've been working on creating a WAR the last several hours. I don't have 10g AS here at home, so I've been testing the deployment of the WAR on Tomcat.
    If the WAR deploys all right in something like Tomcat, will it deploy correctly in 10g AS also?
    Are there any "gotchas" that I should be aware of ahead of deploying the WAR on 10g AS?
    Also, I have a bunch of JSPs, but in the the web.xml that I'm using in my testing, it seems to work even though I don't list all of the JSPs. Here's what I have:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
         <servlet>
              <servlet-name>foo1</servlet-name>
              <jsp-file>foo1.jsp</jsp-file>
         </servlet>
         <display-name>WhatEverNameYouWantDisplayed</display-name>
         <description>replace this with a short description</description>
         <welcome-file-list>
              <welcome-file>foo.html</welcome-file>
         </welcome-file-list>
    </web-app>
    Is that (only including one pair of <servlet-name> and <jsp-file> tags all right, or do I have to include a pair of tags for EACH JSP?
    Other than the above, hopefully things will go all right tomorrow... I'm going to have to undo the edits that I did manually on mod_oc4j.conf (the Mount...) and in server.xml before I try the WAR deploy, I think, right?
    Jim

  • Using java class and variables declared in java file in jsp

    hi everyone
    i m trying to seperate business logic form web layer. i don't know i am doing in a right way or not.
    i wanted to access my own java class and its variables in jsp.
    for this i created java file like this
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static void main(String args[]){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                String  str = rs.getString("Name");
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }next i created a jsp where i want to access String str defined in java class above.
    <%--
        Document   : fisrt
        Created on : Jul 25, 2009, 3:00:38 PM
        Author     : REiSHI
    --%>
    <%@page import="ris.NewClass"%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!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=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1><%=str%></h1>
        </body>
    </html>I wanted to print the name field extracted from database by ResultSet.
    but it gives error cannot find symbol str.
    please help me to find right way to do this.
    i am using netbeans ide.

    Very bad approach
    1) Think if your table contains more than one NAMEs then you will get only the last one with your code.
    2) Your String is declared as local variable in the method.
    3) You have not created any object of NewClass nor called the method in JSP page. Then who will call the method to run sql?
    4) Your NewClass contains main method which will not work in web application, it's not standalone desktop application so remove main.
    Better create an ArrayList and then call the method of NewClass and then store the data into ArrayList and return the ArrayList.
    It should look like
    {code:java}
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static ArrayList getNames(){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            ArrayList nameList = new ArrayList();
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                nameList.add(rs.getString("Name"));
               return nameList;
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                   </code><code class="jive-code jive-java"><font>return nameList;</code><code class="jive-code jive-java">
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
          </code><code>return nameList;</code>
    <code class="jive-code jive-java">    }

  • How can i create  Jar file using Eclipse IDE.

    Hi Guys
    Am new to java. I want convert my project into executable jar file.
    In my project am using itext.jar.And some other folder.
    already i create jar file.But its not working.only its working 4 modules after that its say file cannot found exception.but the file path is correct.i dont know why its happen.
    This is my project folder strutre also
    Log:->
    src(folder)
    logs(folder)
    comments(folder)
    lib-->itext.jar.
    images-->1,gif
    properties-->catconfig.properties (file)
    now can i create jar file
    this code also show error when i run the jar file
    And this is my catconfig. properties file
    fileName=total_system_log.log
    DDSingle=DD_bysingleIP_comment.txt
    DDRange=DD_byrange_comment.txt
    NDPing=ping_comments.txt
    NDFPing=fping_comments.txt
    reportFileName=report.txt
    moduleFileName=Modules.txt
    propFileName=nameDetails.properties
    Choice=DDSingle
    logFileName=DDSingleIP_10.32.0.2.log
    finalReport=FinalReport.txt
    logFilePath=\logs\
    commentFilePath=\\Comments\\
    its very urgent for me . could u pls send my error  and u r ideas.
    thanks for u r Ansewering.
    import java.io.BufferedReader;
    import java.io.DataOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.InputStream;
    import java.io.RandomAccessFile;
    import java.util.Properties;
    import java.util.ResourceBundle;
    import java.util.ArrayList;
    public class LogReader {  
        public void getValuesFromFilesOnly(String Choice,String logFileName)
              try {
                   ArrayList commentsList = new ArrayList();
                   ArrayList tempList = new ArrayList();
                   String userdir = System.getProperty("user.dir");
                   String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   String commentDir =ResourceBundle.getBundle("catconfig").getString(Choice);
                   String commentFilePath=ResourceBundle.getBundle("catconfig").getString("commentFilePath");
                   String currentdir1 =userdir+logFilePath+logFileName;
                   StringBuffer strBuff=new StringBuffer();
                   RandomAccessFile randomFile = null;
                   RandomAccessFile commentsFile = null;
                   String tempLine = null;
                   String commentLine = null;
                   String catVersion = null;
                   String finalReport=null;
                   int colon = 0;                    
                   int counter = 0;
                   boolean startFlag = false;
                   boolean endFlag = false;                    
                   boolean endOfFileFlag = false;          
                   System.out.println("Log file checked----->"+currentdir1);
                   System.out.println("comments file used--->"+commentDir);
                   try {
                        randomFile = new RandomAccessFile(currentdir1, "r");
                   } catch (Exception e) {
                        System.out.println("exception@getValuesFromFilesOnly@begin : "+e);
                   System.out.println("hi test1");
                   String commentDir1=userdir+commentFilePath+commentDir;
                   try{
                   System.out.println("Comment Dir:"+commentDir1);
                   commentsFile = new RandomAccessFile(commentDir1, "r");
                   catch (Exception e) {
                        System.out.println("exception@getValuesFromCommentDirOnly@begin : "+e);
                   while ((commentLine = commentsFile.readLine()) != null) {                         
                        String checkLine = commentLine.substring(commentLine.indexOf("=")+1, commentLine.length());
                        String message = commentLine.substring(0,commentLine.indexOf("="));
                        commentsList.add(checkLine);
                   commentsFile.close();
                   String startComment = (String)commentsList.get(0);
                   String endComment = (String)commentsList.get(commentsList.size()-1);
                   strBuff.append("                          CAT LOG REPORT                           \n\n");
                   while ((tempLine = randomFile.readLine()) != null) {               
                        if(tempLine.contains("CAT version is :"))
                             colon = tempLine.indexOf("is :");
                             catVersion = tempLine.substring(colon+4,tempLine.length());
                             String version=tempLine;
                             strBuff.append("Version : "+catVersion+"\n");
                             System.out.println("catVersion is :"+catVersion);
                        commentsFile = new RandomAccessFile(commentDir1, "r");
                        while ((commentLine = commentsFile.readLine()) != null) {
                             String checkLine = commentLine.substring(commentLine.indexOf("=")+1, commentLine.length());
                             String message = commentLine.substring(0,commentLine.indexOf("="));
                             checkLine=checkLine.toLowerCase();
                             tempLine=tempLine.toLowerCase();
                             if(tempLine.contains(checkLine))
                                  colon = tempLine.indexOf("info -");
                                  catVersion = tempLine.substring(colon+7,tempLine.length());
                                  strBuff.append(message+" ==> "+catVersion+"\n");
                                  System.out.println(message+" ==> "+catVersion);
                                  tempList.add(message+" ==> "+catVersion);
                                  if (catVersion.contains(startComment)){
                                       startFlag = true;
                                       counter++;
                                       System.out.println("*******startFlag**********"+startFlag);
                                  if (catVersion.contains(endComment)){
                                       endFlag = true;
                                       System.out.println("*******endFlag**********"+endFlag);
                                  if (startFlag == true && endFlag == true){
                                       System.out.println("******************************************");
                                       System.out.println("-------------Successfull completion-------");
                                       System.out.println("******************************************");
                                       startFlag = false;
                                       endFlag = false;
                                       counter = 0;
                                       tempList.clear();
                                  if (startFlag == true && endFlag == false && counter > 1){
                                       System.out.println("******************************************");
                                       System.out.println("---------------Failure after-----:"+tempList.get(tempList.size()-1));
                                       System.out.println("******************************************");
                                       //startFlag = false;
                                       //endFlag = false;
                                       counter = 0;
                                       tempList.clear();
                        commentsFile.close();
                   endOfFileFlag = true;
                   if (startFlag == true && endFlag == false && endOfFileFlag == true){
                        System.out.println("******************************************");
                        System.out.println("---------------Failure after-----:"+tempList.get(tempList.size()-1));
                        System.out.println("******************************************");
                        startFlag = false;
                        endFlag = false;
                        counter = 0;
                        tempList.clear();
                   randomFile.close();
                 System.out.println("hi");
                   finalReport=ResourceBundle.getBundle("catconfig").getString("finalReport");
                   savereportFile(strBuff,finalReport);
                   System.out.println("Report Generated");
              } catch (Exception e){
                   System.out.println("Exception@getValuesFromFilesOnly : "+e);
        public void findDetails()
             String currentdir1 = ResourceBundle.getBundle("catconfig").getString("fileName");     
             String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
             String userdir = System.getProperty("user.dir");
             RandomAccessFile randomFile = null;
             StringBuffer strBuff=new StringBuffer();
             StringBuffer strBuff1=new StringBuffer();
             StringBuffer strBuff2=new StringBuffer();
             String tempLine = null;     
              String catVersion = null;
              String timeStr=null;
              String nameStr=null;
              String startIP="";
              String endIP="";
              String tempStart="";
              String tempEnd="";
              String reportFileName="";
              String moduleFileName="";
              String propFileName="";
              int startPos=0;
              int endPos=0;
              int fromIndex=0;
              boolean versionFlag=false;
              boolean ndFlag=false;
              boolean ddFlag=false;
              try {
                   randomFile = new RandomAccessFile(userdir+logFilePath+currentdir1, "r");
                   while ((tempLine = randomFile.readLine()) != null) {
                        if(tempLine.contains("CAT version is :") && !versionFlag)
                             startPos = tempLine.indexOf("is :");
                             catVersion = tempLine.substring(startPos+4,tempLine.length());
                             String version=tempLine;
                             strBuff.append("version : "+version+"\n");
                             versionFlag=true;
                             //System.out.println("version : "+version);
                        if(tempLine.contains("Inside NetworkDiscoverySlider.jsp"))
                             ndFlag=true;
                             strBuff.append("ND start : "+tempLine+"\n");                         
                        if(tempLine.contains("Inside NetworkDiscoveryDetails.jsp"))
                             strBuff.append("ND end : "+tempLine+"\n");
                             //System.out.println(" ND end : "+tempLine);
                        if(tempLine.contains("Given IPRange from"))
                             startPos = tempLine.indexOf("from");
                             catVersion = tempLine.substring(startPos+5,tempLine.length());
                             strBuff.append("NDRange : "+catVersion+"\n");     
                             //strBuff.append("NDRange : "+tempLine+"\n");                                             
                             //System.out.println("NDRange :"+catVersion);     
                             startPos=0;
                             fromIndex=tempLine.indexOf(":");
                             endPos= tempLine.indexOf(':', fromIndex+2);
                             //System.out.println("fromIndex : "+fromIndex+" endPos : "+endPos);
                             timeStr=tempLine.substring(startPos, endPos);
                             nameStr=catVersion.replaceAll(" ", "_");                         
                             strBuff2.append("ND_"+timeStr+" "+catVersion+" = "+"NDRange_"+nameStr+".log\n");
                        if(tempLine.contains("inside ByIpAddress.jsp"))
                             ddFlag=true;
                             strBuff.append("DD Start : "+tempLine+"\n");                                                  
                        if(tempLine.contains("start_IpAddress:"))
                             startPos = tempLine.indexOf("start_IpAddress:");
                             catVersion = tempLine.substring(startPos+16,tempLine.length());
                             startIP=catVersion;                         
                        if(tempLine.contains("end_IpAddress"))
                             startPos = tempLine.indexOf("end_IpAddress");
                             catVersion = tempLine.substring(startPos+13,tempLine.length());
                             endIP=catVersion;                         
                             if(endIP.length()==0)
                                  System.out.println("hi5");
                                  strBuff.append("DDSingleIP : "+startIP+"\n");
                                  //strBuff.append("DDSingleIP : "+tempLine+"\n");                              
                                  //System.out.println("DDSingleIP : "+startIP);
                                  //startPos = tempLine.indexOf(" ");
                                  startPos=0;
                                  fromIndex=tempLine.indexOf(":");
                                  endPos= tempLine.indexOf(':', fromIndex+2);
                                  timeStr=tempLine.substring(startPos, endPos);     
                                  strBuff2.append("DD_"+timeStr+" "+startIP+" = "+"DDSingleIP_"+startIP+".log\n");
                             else
                                  strBuff.append("DDRangeIP : "+startIP + " to "+ endIP+"\n");
                                  //strBuff.append("DDRangeIP : "+tempLine+"\n");                              
                                  //System.out.println("DDRangeIP : "+startIP + " to "+ endIP);
                                  //startPos = tempLine.indexOf(" ");
                                  startPos=0;
                                  fromIndex=tempLine.indexOf(":");
                                  endPos= tempLine.indexOf(':', fromIndex+2);
                                  timeStr=tempLine.substring(startPos, endPos);                         
                                  strBuff2.append("DD_"+timeStr+" "+startIP+" to "+endIP+" = "+"DDRangeIP_"+startIP +"_to_"+ endIP+".log\n");
                        if(tempLine.contains("set percentage completedCount: 100"))
                             System.out.println("hi...1");
                             strBuff.append("DD End : "+tempLine+"\n");
                             //System.out.println("DD End : "+tempLine);          
                   reportFileName=ResourceBundle.getBundle("catconfig").getString("reportFileName");
                   savereportFile(strBuff,reportFileName);
                   if(ndFlag)
                        strBuff1.append("Network Discovery\n");                    
                   if(ddFlag)
                        strBuff1.append("Device Discovery\n");
                   moduleFileName=ResourceBundle.getBundle("catconfig").getString("moduleFileName");
                   savereportFile(strBuff1,moduleFileName);
                   propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                   savereportFile(strBuff2,propFileName);
              } catch (Exception e)
                   System.out.println("error hi1");
                   System.out.println("Exception@findDetails : "+e);
        public void savereportFile(StringBuffer strBuff,String targetFileName)
              try{
                   String userdir = System.getProperty("user.dir");
                   String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   String reportFile=userdir+logFilePath+targetFileName;     
                   String fileContent="";
                   fileContent=strBuff.toString();
                      //System.out.println("file content : "+fileContent);
                      FileWriter fileWriter = new FileWriter(reportFile);
                      if(fileContent!=null)
                           fileWriter.write(fileContent);
                      fileWriter.close();
              catch(Exception e)
                   System.out.println("error hi1");
                   System.out.println("Exception@savereportFile : "+e);
        public ArrayList<String> getFileNames()
             String reportFile=ResourceBundle.getBundle("catconfig").getString("reportFileName");
             String logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
             String userdir = System.getProperty("user.dir");
              RandomAccessFile repFile=null;
              String reportLine = null;
              int colon=0;
              int fromIndex=0;     
              int startPos=0;
              int endPos=0;
              String timeStr="";
              String fileName=null;          
              ArrayList<String> nameList=new ArrayList<String>();          
             try
                  reportFile=userdir+logFilePath+reportFile;
                  repFile = new RandomAccessFile(reportFile, "r");
                  while ((reportLine = repFile.readLine()) != null) {                    
                        if(reportLine.contains("NDRange"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="NDRange_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                        if(reportLine.contains("DDSingleIP"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="DDSingleIP_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                        if(reportLine.contains("DDRangeIP"))
                             colon=reportLine.indexOf(" : ");
                             fileName=reportLine.substring(colon+3, reportLine.length());
                             fileName="DDRangeIP_"+fileName.replaceAll(" ", "_");
                             nameList.add(fileName);
                             System.out.println("fileName : "+fileName);
                  repFile.close();
             catch(Exception e)
                   System.out.println("Error@getFileNames : "+e);
             return nameList;
        public void writeFile(String oldLogName,String newLogName)
             try
                   FileOutputStream writeFile=null;               
                   String line = null;
                   String userdir = System.getProperty("user.dir");
                   String reportFile=ResourceBundle.getBundle("catconfig").getString("reportFileName");     
                   String newLogPath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                   RandomAccessFile repFile=null;               
                   String reportLine = null;
                   String tempLine=null;
                   String prevLine=null;
                   String nextLine=null;
                   String target=null;
                   String tempStr=null;
                   String startStr=null;
                   String endStr=null;          
                   int pos=0;
                   boolean flag=false;
                   boolean writeFlag=false;
                   boolean versionFlag=false;               
                   //System.out.println("newLogName : "+newLogName);     
                   newLogPath=userdir+newLogPath;
                   System.out.println("newLogPath : "+newLogPath);     
                   BufferedReader buffRead = new BufferedReader(new FileReader(oldLogName));
                   writeFile = new FileOutputStream(newLogPath+newLogName+".log", false);//true-for append mode
                   DataOutputStream dout=new DataOutputStream(writeFile);               
                   tempStr=newLogName.replace("_", " ");
                   pos=tempStr.indexOf(" ");
                   startStr=tempStr.substring(0,pos);
                   endStr=tempStr.substring(pos+1, tempStr.length());
                   target=startStr+" : "+endStr;
                   System.out.println("target ===> "+target);               
                   reportFile=newLogPath+reportFile;
                   repFile = new RandomAccessFile(reportFile, "r");
                  while ((reportLine = repFile.readLine()) != null) {                   
                       if(reportLine.contains(target))
                            flag=true; 
                            prevLine=tempLine;
                            //System.out.println("prevLine *****: "+prevLine);
                       else
                            tempLine=reportLine;
                            if(flag==true)
                                 nextLine=reportLine;
                                 flag=false;
                                 //System.out.println("nextLine *******:"+nextLine);
                                 break;
                  repFile.close();     
                 if(prevLine!=null && prevLine.length()>0)
                       pos=prevLine.lastIndexOf(" : ");
                       prevLine=prevLine.substring(pos+3, prevLine.length());
                       //System.out.println("prevLine : "+prevLine);
                  else
                       System.out.println("Starting line not available for : "+target);
                  if(nextLine!=null && nextLine.length()>0)
                        pos=nextLine.lastIndexOf(" : ");
                        nextLine=nextLine.substring(pos+3, nextLine.length());
                        //System.out.println("nextLine : "+nextLine);
                  else
                       System.out.println("Ending line not available for : "+target);
                       nextLine=prevLine;
                   while ((line=buffRead.readLine()) != null) {     
                        if(line.contains("CAT version is :") && !versionFlag)
                             versionFlag=true;
                             dout.writeBytes(line+"\n");                         
                        if(line.contains(prevLine))
                             writeFlag=true;                         
                        if(line.contains(nextLine))
                             writeFlag=false;
                             break;
                        if(writeFlag)
                             dout.writeBytes(line+"\n");
                  dout.writeBytes(nextLine+"\n");
                   buffRead.close();     
                   System.out.println("done");
              catch(Exception e)
                   System.out.println("Exception@writeFile : "+e.getMessage());
        public String folderCheck(String foldName)
              File folder=null;
              File newFile=null;
              String[] folderContent=null;
              String tempFileName="";
              String newLogName="";
              int count=0;     
              String logFilePath="";     
              String fileName="";
              String feedBackMsg="";          
              String userdir = System.getProperty("user.dir");
              logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
              fileName=ResourceBundle.getBundle("catconfig").getString("fileName");
              folder=new File(foldName);
              if(folder.isDirectory())
                   newLogName=userdir+logFilePath+fileName;
                   //System.out.println("newLogName : "+newLogName);
                   newFile=new File(newLogName);
                   if(newFile.exists())
                        newFile.delete();
                   folderContent= folder.list();
                   if (folderContent != null && folderContent.length>0)
                        System.out.println("folder has files : "+folderContent.length);                    
                        for(int iterate=0;iterate < folderContent.length;iterate++){                         
                             if (folderContent[iterate].toLowerCase().contains("system"))
                                  count++;                              
                                  tempFileName=foldName+"/"+folderContent[iterate];     
                                  try
                                       FileOutputStream appendedFile=null;
                                       BufferedReader buffRead = new BufferedReader(new FileReader(tempFileName));
                                       appendedFile = new FileOutputStream(newLogName, true);//true-for append mode
                                        DataOutputStream dout=new DataOutputStream(appendedFile);
                                        String line = null;
                                       System.out.println("writting : "+tempFileName);
                                       while ((line=buffRead.readLine()) != null) {                                        
                                            dout.writeBytes(line+"\n");
                                       buffRead.close();          
                                       //System.out.println("done");
                                  catch(Exception e)
                                       System.out.println("Exception@folderCheck : "+e);
                        if(count==0)
                             feedBackMsg="syslognotavail";
                             //System.out.println("System Log(s) not available");
                        else
                             feedBackMsg="syslogavail";
                             //System.out.println(count +" System log(s) avail");
                   else
                        feedBackMsg="filesnotavail";
                        //System.out.println("Files are not in the folder");
              else
                   feedBackMsg="Dirnotavil";
                   //System.out.println("Directory not exists in the given name");
              return feedBackMsg;
        public ArrayList<String> loadFileContent(String selectedStr)
             //System.out.println("inside loadFileContent()");
             String logFilePath="";
             String propFileName="";
             String line="";
             String choice="";
             String tempStr="";
             int startPos=0;
             int endPos=0;
             ArrayList<String> timeList=new ArrayList<String>();
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                  propFileName=userdir+logFilePath+propFileName;
                  BufferedReader buffRead = new BufferedReader(new FileReader(propFileName));
                  if(selectedStr.equalsIgnoreCase("Device Discovery"))
                       choice="DD";
                  else if(selectedStr.equalsIgnoreCase("Network Discovery"))
                       choice="ND";
                  while ((line=buffRead.readLine()) != null) {                                        
                        if(line.contains(choice))
                             System.out.println(line);
                             startPos=line.indexOf("_");
                             endPos=line.indexOf(" =");
                             tempStr=line.substring(startPos+1, endPos);
                             System.out.println("tempStr : "+tempStr);
                             timeList.add(tempStr);
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFileContent : "+e);
             return timeList;
        public String getFileName(String timeStr)
             System.out.println("inside getFileName");
             String logFilePath="";
             String propFileName="";
             String line="";
             String tempStr="";
             int startPos=0;
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  propFileName=ResourceBundle.getBundle("catconfig").getString("propFileName");
                  propFileName=userdir+logFilePath+propFileName;              
                  BufferedReader buffRead = new BufferedReader(new FileReader(propFileName));              
                  while ((line=buffRead.readLine()) != null) {                                        
                        if(line.contains(timeStr))
                             System.out.println(line);
                             startPos=line.indexOf(" = ");                         
                             tempStr=line.substring(startPos+3, line.length());
                             System.out.println("tempStr : "+tempStr);                         
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFileContent : "+e);
             return tempStr;
        public ArrayList loadFile()
             String logFilePath="";
             String moduleFileName="";
             String line="";         
             ArrayList<String> moduleList=new ArrayList<String>();
             String userdir = System.getProperty("user.dir");
             try
                  logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
                  moduleFileName=ResourceBundle.getBundle("catconfig").getString("moduleFileName");
                  moduleFileName=userdir+logFilePath+moduleFileName;
                  BufferedReader buffRead = new BufferedReader(new FileReader(moduleFileName));              
                  while ((line=buffRead.readLine()) != null) {     
                       moduleList.add(line);                    
                   buffRead.close();          
             catch(Exception e)
                  System.out.println("Exception@loadFile : "+e);
             return moduleList;
    public static void main(String[] args) {          
         System.out.println("Inside main");     
         //String userdir = System.getProperty("user.dir");
         //System.out.println("userdir : "+userdir);
         /*ArrayList<String> fileNameList=new ArrayList<String>();
         String Choice="";     
         String logFileName="";     
         String logFilePath="";     
         String totalLog="";     
         String newLog="";     
         String folderName="";
         Choice=ResourceBundle.getBundle("catconfig").getString("Choice");
         logFileName=ResourceBundle.getBundle("catconfig").getString("logFileName");     
         logFilePath=ResourceBundle.getBundle("catconfig").getString("logFilePath");
         folderName=ResourceBundle.getBundle("catconfig").getString("folderName");
         totalLog=ResourceBundle.getBundle("catconfig").getString("fileName");     */
         /*try
              //to write the total log
              //folderCheck(folderName);
              //to find the details in the given log
              //findDetails();
              //to split the logs accordingly
              totalLog=logFilePath+totalLog;          
              fileNameList=getFileNames();;
              System.out.println("FileNameList size = "+fileNameList.size());
              for(int i=0;i<fileNameList.size();i++)
                   newLog=fileNameList.get(i).toString();
                   writeFile(totalLog,newLog);
              //to analyse the logs & to produce reports          
              //getValuesFromFilesOnly(Choice,logFileName);          
         }catch (Exception e)
              System.out.println(e.getMessage());
    }[                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    JSP is used for server validation.
    So you need a an application server (like Tomcat or Jboss) to execute your jsp files.
    you can create the .war file of your simple jsp application and put it in the server.
    then you will have to access your page using a web browser.
    the URL will be
    http://<ComputerName or IP Address>:<PortNumber>/<WarFileName>/<MainJspPage>
    (eg: http://100.100.100.252:8080/SimpleApplication/mainPage.jsp)
    -Achyuth

  • How can I create a file uploader for my website

    I am looking for a solution for creating a file uploader interface for my website. I need to accept files on a users local machine and upload them to designated directory on my server. Can I do this with JSP? Any advice or help would be appreciated
    Thanks
    Stephen Rogouski

    See for example Upload taglib from Coldtags suite:
    http://www.servletsuite.com/jsp.htm

  • How to import a jar file in JSP

    How to import a Jar file in JSP Page.
    please reply its very urgent!

    Hey I am facing a similar problem:
    I have this jar file lbswebservice.jar that I have to use for my application.
    I added it to the classpath, I copied it in my WEB-INF/lib folder, but when I try to access classes in this package, it doesnt work.
    For example the jar contains the package com.blipsystems.lbs.ws.messages.* ; that contains different classes, like the Campaign class.
    I tried to use this class (just to create an object) in different context (through jsp, or just through java test classes), but it never works, i get the error: com.blipsystems.lbs.ws.messages.Campaign cannot be resolved to a type
    I am a bit desperate here...

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • Read an excel file using JSP in MII 12.1

    Hi,
    I want to read an excel file using jsp page. I dont want to use the UDS or ODBC for connecting to excel.
    I am trying to use org.apache.poi to read the excel file in jsp page.
    While running, its showing a compilation error "package org.apache.poi.hssf.usermodel does not exist"
    I have the jar files for it, where do we need to upload it so that jsp page works.
    Thanks a lot
    Regards,
    Neha Maheshwari

    The user doesn't want to save the excel file in server.
    I want to upload file and save its contents in database.
    I have the code to read and save excel data in database but not able to get the location to deploy the jar file.
    In general, if we are creating a jsp page in MII workbench which is using some jar file.
    Whats the location to upload this jar file so that the jsp page works correctly?

  • Pls help!  Creating a new simple jsp iView...

    Hi, I would like to create a totally new iView JSP project from scratch.  I currently have NetWeaver and EP 6.0.  This is what I have done so far on NetWeaver: <b>File > New > Project > Select Portal Application > click 'Next' > Type in Project name and root folder > click 'FINISH'</b>.  Now, I think I have a project ready?  I have some basic iView JSP code already.   so now can someone provide me with detailed steps on what modifications and steps I need to make on my new project in order for my iView jsp to display on the EP 6.0?  Any files like 'portalapp.xml' that I have to modify?
    Thank you so much for your help,
    Baggett.
    What I know so far: I have looked at an example where I created one using an existing par.  I know how to export .par file to EP 6.0, it's the steps before that I don't know.  Thanks again.

    Hi, I think I found a little solution to my problem but now I have a new issue.  I think I "solved" my problem by doing:  <b>File > New > Project > Select Portal Application > click 'Next' > Type in Project name and root folder > click 'FINISH'.  Now, I do:
    File > New > Other > Portal Application > Create a new Portal Application Object > Select my Project > Portal Component/JSPDynPage (is this the 'easy' one to pick b/c it seems to update the portalapp.xml file, creates a jsp file (myFirstJSP.jsp) and bean for me) > I type in all the textfields for file name, package name, ... > click 'FINISH'. </b>
    Is this a correct/good way of starting a JSP project(I don't really know what a JSPDynPage is)
    Now I have a new issue.  I open up myFirstJSP.jsp and NetWeaver highlights all the code (pasted below) in yellow and there is no error displayed:
    <b><hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
       </hbj:form>
      </hbj:page>
    </hbj:content></b>
    So I try to paste this line into myFirstJSP.jsp: <b><%@ taglib uri="tagLib" prefix="hbj" %></b>and also paste this line onto portalapp.xml:
    <b><component-profile>
            <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
    </component-profile>    </b>
    Now, I get an error saying: <b>"JSP Parsing Error:File "/dist/PORTAL_INF/pagelet/tagLib" not found"</b>
    Why is this?  How can I fix it?
    Thanks so much,
    Baggett.

Maybe you are looking for