Using jsp:getProperty ... inside a scriptlet

When I use the following line in a jsp file,
<% boolean userExists=<jsp:getProperty name="xxx" property="exist/> %>
it gives an error saying that a term is missing, when I try to load this page. Any help is appreciated.
Thanks,
Nalini

Don't put the bean in the servlet context but use the HttpSession
session.setAttribute("xxx", loginBean);
in the JSP retrieve the bean by
<jsp:useBean id="xxx"
scope="session"
class="package.LoginBean" />
Where id = the name of the attribute in the session
class = the full package name of the bean.
Or
LoginBean myBean = (LoginBean) session.getAttribute("xxx");
Don't forget the import
<%@ page import="package.LoginBean" %>

Similar Messages

  • Populating combobox in jsp page from javabean using jsp:getProperty tag

    hi,
    i am new to jsp, so i don;t know how to populate a combobox in jsp page with productid attribute from a javabean called Bid . i want to have a code to automatically populating combobox using the attribute value from javabean.
    please reply me.
    <jsp:useBean id="bidpageid" class="RFPSOFTWARE.Bid" scope="session" />
    <jsp:setProperty name="bidpageid" property="*"/>
      <table  width="50%" align="center" border="0">
       <tr>
        <td  width="30%" align="left"><h4><b><label>Date (dd/mm/yyyy) </label></b></h4> </td>
        <td><input type="text" name="date" size="11" maxlength="10" readonly="readonly" value="<jsp:getProperty name="bidpageid" property="date"/>"  > </td>
      </tr>
      <tr> <td > </td> </tr>
      <tr>
        <td  width="30%" align="left"><h4><b><label>ProductId </label></b></h4> </td>
        <td><select name="productid" tabindex="1" size="1" >
          <option  value="<jsp:getProperty name=bidpageid" />Sachin</option>
          <option value="Hello">Vishal</option>
        </select></td>
      </tr>  and the javabean for Bid is as follow :
    import java.util.Date;
    import RFPSOFTWARE.Product;
    public class Bid{
    private Product product;
    private Integer bid_id;
    private String description;
    private Date date= new Date();
    public Integer getBid_id() {
    return bid_id;
    public Date getDate() {
    return date;
    public String getDescription() {
    return description;
    public Product getProduct() {
    return product;
    public void setBid_id(Integer bid_id) {
    this.bid_id = bid_id;
    public void setDate(Date date) {
    this.date = date;
    public void setDescription(String description) {
    this.description = description;
    public void setProduct(Product product) {
    this.product = product;
    }

    No Sir,
    I think I did not explained clearly.what I try to say is I dont want to use JSTL.I am using only Scriptlets only.I can able to receive the values from the database to the resultset.But I could not populate it in Combobox.
    My code is :
    <tr>
    <td width="22%"><font color="#000000"><strong>Assign To Engineer</strong></font></td>          
    <td width="78%">
         <select NAME="Name" size="1">
    <option><%=Username%></option>
    </select> </td>
    </tr>
    in HTML
    and in Scriptlets:
    ps1 = con.prepareStatement
              ("SELECT Username FROM Users");
              rs2=ps1.executeQuery();
              System.out.println("SECOND Succesfully Executed");
              while(rs2.next())
                   System.out.println("Coming inside rs2.next loop to process");
                   Username=rs2.getString("Username");
                   System.out.println("Success");
                   System.out.println("The value retrieved from UsersTable Username is:"+Username);
    In the server(Jboss console) I can able to display the username but I could not populate it in the Combobox .
    Can you now suggest some changes in my code,Please..
    Thanks a lot
    With kind Regds
    Satheesh

  • Using JSP variable inside Java Script's alert function.

    Hi Gurus,
    We are trying to use alert function with one of the string variables populated inside JSP code, but its not working.
    Here is the code snippet, please advice.
         <%
         oracle.apps.qot.util.RequestCtx.log("qotcustom.jsp",AOLMessageManager.getMessageSt(QotUtil.QOT_APPS_CODE, "XDPYY_DISC"));
         %>
         var alert_text="<%=AOLMessageManager.getMessageSt(QotUtil.QOT_APPS_CODE, "XDPYY_DISC")%>";
         alert(alert_text);
         Here in the first line we are using API to get text message defined in database, the line is getting executed properly and we could see output text message in debug log file, after this in the 4th line, we are assiging this string output of API to java script variable alert_text and further using alert function with the variable alert_text as argument. But alert function is failing, no errors are thown in debug log file.
    Please advice whether we are doing any thing wrong.
    Thanks in advance.

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • Regarding jsp:getProperty

    hi
    i have a bean. I am setting the values of the bean and setting that bean as an attribute in the session.
    In another jsp i am able to access the bean using
    <jsp:getProperty name=".." property="..">
    Here the name is the same as the attribute name.
    But here i am not using <jsp:useBean /> tag.
    I have read some where that <jsp:getProperty> or <jsp:setProperty> should be used with the <jsp:useBean> tag.
    Please correct me where i am wrong?

    I too read the same.
    But i done an example on my local machine and i am able to access the <jsp:getProperty> without <jsp:useBean>
    Consider Testbean.jsp
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>TestBean.jsp</TITLE>
    </HEAD>
    <BODY>
    <%
    InfoBean infoBean = new InfoBean();
    infoBean.setFullname("Macro");
    infoBean.setAge("23");
    infoBean.setOccupation("employee");
    infoBean.setSex("F");
    infoBean.setQualification("B-Tech");
    session.setAttribute("InfoBeanObj",infoBean);
    %>
    <jsp:forward page = "TestBeanForward.jsp"/>
    </BODY>
    </HTML>
    The TestBeanForward.jsp is
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
    <TITLE>TestBeanForward.jsp</TITLE>
    </HEAD>
    <BODY>
    <jsp:getProperty name="InfoBeanObj" property="fullname"/>
    <jsp:getProperty name="InfoBeanObj" property="age"/>
    <jsp:getProperty name="InfoBeanObj" property="occupation"/>
    <jsp:getProperty name="InfoBeanObj" property="sex"/>
    <jsp:getProperty name="InfoBeanObj" property="qualification"/>
    </BODY>
    </HTML>
    I ran TestBean.jsp on server and i am able to print all the values onthe browser

  • Can any one answer me how to import and use jsp libraries into uix file and

    Hi guys
    can any one help me how to import jsp libraries in to my uix file with jdev 10g production adn how to use them..if any one got any sample for this i appreciate if u cans end me that
    thanks
    Venkat

    you cannot use jsp tags inside uix xml pages.
    you can, however, use uix jsp tags inside jsp pages.

  • Is it possible to find and Replace a string inside a textfile using JSP?

    FileInputStream fs = new FileInputStream("/opt/Abhishek/software/tomcat/webapps/AMS/listpass");
    DataInputStream in1 = new DataInputStream(fs);
    while (in1.available() !=0)
    String str1=in1.readLine();
    StringTokenizer st1 = new StringTokenizer(str1);
    String node=st1.nextToken();
    if (node.equals(sports))
    String pass=st1.nextToken();
    out.println ("<b>"+sports[i]+" <b>");
    out.println("**Your Required Password**");
    out.println(pass);
    out.println("<br></br>");
    %>
    Hi ,
    I have a text file (named listpass in the above code) inside tomcat-webapps folder containing a node name and its password.You could see the path of the text file at the starting line of the code.The Scene behind the program is once the particular node is clicked the password is retreived for the user against the particular node.What i would need is to change the password in the text file once it is retreived. So i would need to find the password that is retreived recently and change that one with a randomnly generated new password in the text file.
    So can i do this?Is it possible to search for the string in the text file and replace that with a new one using JSP.For your note i am running all my HTML amd JSP inside the same folder where i have the text file in which the string has to be replaced .
    Could anyone give your comments on this please?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Nasty in so many ways.
    First off you shouldn't be doing stuff like this in a JSP. JSPs should just build HTML, use a Servlet and then pass data to a JSP for formatting.
    Web applications are multi-threaded, so you have to consider what happens if several of these transactions come in at the same time, each trying to change the same data file.
    It's not practical to amend text files in place, generally you have to create a new version of the file for each change because if the size of a password changes the subsequent bytes of the file would all need moving.
    Use a database. Databases are designed to deal with these issues and there are perfectly good free ones around like Derby, MySQL and H2.

  • Problem using jsp:include from inside a custom tag

    Hi, All !
              I have a problem using <jsp:include> from inside a custom tag. Exception is:
              "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              could not do this. Is it a bug, since in the 1.1 spec is said: "The
              BodyContent is a subclass of JspWriter that can be used to process body
              evaluations so they can retrieved later on."
              My code is:
              <wfmklist:items>
              <jsp:include page="item.jsp" flush="true"/>
              </wfmklist:items>
              

    This is an area of contention with WL. It is not so tolerant with regards to
              the spec. I spent several days recently trying to convince it to accept the
              specification in regards to bodies and includes and it appears to have
              successfully rebuffed my efforts.
              Frankly, this is very disappointing. It appears that some shortcuts were
              taken on the way to JSP 1.1 support, and the result is a very hard-coded,
              inflexible implementation. As I have not seen the implementation myself, I
              hate to assume this, however one could posit that the term "interface" was a
              foreign concept during the implementation, other than as some annoying
              intermediary reference requiring an immediate cast to a specific Weblogic
              class, which in turn is apparently required to be final or have many final
              methods, as if being optimized for a JDK 1.02 JIT.
              I am sorry that I don't have any positive suggestions other than to use a
              URL object to come back in an execute the necessary "include" directly. You
              lose all context (other than session) and that can cause its own problems.
              However, you can generally get the URL approach to work, and you will
              hopefully avoid further frustration.
              Peace,
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              Tangosol: How Weblogic applications are customized
              "Denis" <[email protected]> wrote in message
              news:[email protected]...
              > Hi, All !
              > I have a problem using <jsp:include> from inside a custom tag. Exception
              is:
              > "java.lang.ClassCastException: weblogic.servlet.jsp.BodyContentImpl"
              >
              > Apparently, weblogic tries to cast BodyContentImpl to JspWriterImpl and
              > could not do this. Is it a bug, since in the 1.1 spec is said: "The
              > BodyContent is a subclass of JspWriter that can be used to process body
              > evaluations so they can retrieved later on."
              >
              > My code is:
              > ...
              > <wfmklist:items>
              > <jsp:include page="item.jsp" flush="true"/>
              > </wfmklist:items>
              > ...
              

  • How to use jsp:scriptlet in site template

    hi all,
    I want to use <jsp:scriptlet> in site template, but jdev showed me an error msg when I put <jsp:scriptlet> in site template:
    scriptlet can not work properly with OJSP, I checked the forums, one possible solution is to encapsulate java code in jsp taglib, but I dislike this solution.
    Is there a way to disable OJSP? or any solution to use java code in site template?
    Best regards

    I believe the official word is if you are trying to use java code in a scriptlet in your site template then you are doing something wrong.
    The goal is to keep java code separate from the template and pages. Any logic should go to your supporting serviece objects and all of your front-end work should be accomplished using available or custom tags.
    Can you describe what you are trying to accomplish with this java code in your template?

  • Using JSP object in Scriptlets

    How to use a jsp object in a scriptlet?
    For example i have this JSP object:
    <script type="text/javascript">
    var jspObject = "UserName";
    </script>And i wanna use it in:
    <%
    String sql = "SELECT * FROM TABLENAME WHERE _USERNAME ='" + (here comes the jsp object) +"'";
    db.query(sql);
    %>

    Hi ,
    Do u want to send mails through Outlook only or u want a java smtp program to send mail that looks same as advertisment mails u get .. i e like webpage ..
    Regards

  • Problem using jsp:forward in java script

    hi,
    when I use jsp forward tag inside java script i'm getting a problem that
    when the jsp is invoked it is getting forwarded to the page specified in the forward tag, without checking the if conditions. Following code may give you a better idea.
    <html>
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    <jsp:forward page="success.jsp" />
    </script>
    <body>
    <form name="f" method=post>
    <input type=text name=htemp value="true">
    <input type=button onclick="test()">
    </form>
    </body>
    </html>
    please help me,thanks inadvance
    regards
    chandu

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • Jsp:getProperty in tag attributes

    Hii....
    I have a custom tag that displays some information based on an attribute of the tag. I want to set information from a bean to the attribute using the jsp:getProperty tag...
    I want to do something like.......
    <mytagprefix:MyTag attribute1='<jsp:getProperty id="myID" property="name"/>' />
    If I do it right now I am getting the string <jsp:getProperty id="myID" property="name"/> inside the my TAG.
    any help will be appreciated.
    sanjay.

    I'm a bit rusty on custom tags, so maybe this isn't the best solution, but until you find a better one you can try '<%= myID.getName() %>' as the attribute.

  • Please!!!!!!   How can i add rows in html table dynamically [use jsp,bean]

    hello, i am a fresher in jsp. i want to add new rows in html table dynamically.In my coding, just only shows in one row . please help my problem with correct coding and i don't want to use database. Thanks ...............!
    Here is my coding-------------------
    ---------------- form.jsp --------------------->
    <%@ page import="java.util.*,newtest1.Validation" %>
    <jsp:useBean id="mybean" scope="page" class="newtest1.Validation" />
    <jsp:setProperty name="mybean" property="name" param="name" />
    <jsp:setProperty name="mybean" property="age" param="age" />
    <% s[i][j] %>
    <html>
    <head><title>Form</title></head>
    <body>
    <form method="get">
    <table border="0" width="700">
    <tr>
    <td width="150" align="right">Name</td>
    <td width="550" align="left"><input type="text" name="name" size="35"></td>
    </tr>
    <tr>
    <td width="150" align="right">Age</td>
    <td width="550" align="left"><input type="text" name="age" size="35"></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <tr><td> </td></tr>
    <tr><td><input type="submit" name="submit" value="ADD"></td></tr>
    <tr><td> </td></tr>
    <tr><td width="100%" align="center" border=1>
    <% int count=mybean.getStart();
    for(int i=count; i<count+1; i++) { %>
    <tr>
    <td><jsp:getProperty name="mybean" property="name" /></td>
    <td><jsp:getProperty name="mybean" property="age" /></td>
    <td><%= count %></td>
    <% count+=1; %>
    </tr>
    <% } %></td></tr>
    </table>
    </form>
    </body>
    </html>
    ----------------- Validation.java ----------------->
    package newtest1;
    import java.util.*;
    public class Validation {
    private String name;
    private String age;
    static int start=0;
    public Validation() {    name=null;
    age=null;
    ++start;}
    public void setName(String username) { if(username!="")
    name=username;
    public String getName() { return name;  }
    public void setAge(String userage) {  if (age!="")
    {age=userage;}
    public String getAge() {  return age;   }
    public int getStart() {
    return start; }

    Hi, Do you mean to say,
    You have an HTML page in which you have a text field and an add button. If you enter anything in that text field and click on Add button the text field contents should be displayed in the same HTML page and you should be able to go on entering new values into the text field and you should be able to retain and display all the previously entered values..
    and finally the list of added items are not stored in the database..
    If this is the case
    i. Your html form should be submitted to the same page.
    ii. You need to have a Vector which holds the entered values.
    iii. Bind the vector object to the request object and collect the same vector object from the request and display its contents...
    I think this would help...

  • Export to Excel from Database using JSP

    Hi Experts,
    I'm using below jsp code to export from an Oracle table to Excel using JSP.
    Every time I run this code I get the exception - "java.lang.OutOfMemoryError: Java heap space".
    I need to download around 8000+ records of the table containing 60 columns.
    I have increased Heap space but still the exception. Below is the code for your reference (I have mentioned only 30 columns where as there are 60 columns in actual). Pls help me what could be the other possible ways or suggest me any alternate code.
    Pls note - Some of the terms like "<serverip>", MySchema, myfile, COL names are changed for confidentiality.
    "D:\\Myfolder\\Excelfolder\\Final.xls" exists my the local machine.
    The code works until some 4000 records & after that throws the exception.
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@<serverip>:1521:WISTGDEV", "user", "user@123");
    Statement statement = connection.createStatement();
    String filename = "C:\\Myfolder\\Excelfolder\\Final.xls";
    String strQuery1 = ("select * from Myschema.myfile");
    ResultSet rs = statement.executeQuery(strQuery1);
    HSSFWorkbook hwb = new HSSFWorkbook();
    HSSFSheet sheet = hwb.createSheet("sheet1");
    HSSFRow rowhead = sheet.createRow((short)0);
    rowhead.createCell((short) 0).setCellValue("COL1");
    rowhead.createCell((short) 1).setCellValue("COL2");
    rowhead.createCell((short) 2).setCellValue("COL3");
    rowhead.createCell((short) 3).setCellValue("COL4");
    rowhead.createCell((short) 4).setCellValue("COL5");
    rowhead.createCell((short) 5).setCellValue("COL6");
    rowhead.createCell((short) 6).setCellValue("COL7");
    rowhead.createCell((short) 7).setCellValue("COL8");
    rowhead.createCell((short) 8).setCellValue("COL9");
    rowhead.createCell((short) 9).setCellValue("COL10");
    rowhead.createCell((short) 10).setCellValue("COL11");
    rowhead.createCell((short) 11).setCellValue("COL12");
    rowhead.createCell((short) 12).setCellValue("COL13");
    rowhead.createCell((short) 13).setCellValue("COL14");
    rowhead.createCell((short) 14).setCellValue("COL15");
    rowhead.createCell((short) 15).setCellValue("COL16");
    rowhead.createCell((short) 16).setCellValue("COL17");
    rowhead.createCell((short) 17).setCellValue("COL18");
    rowhead.createCell((short) 18).setCellValue("COL19");
    rowhead.createCell((short) 19).setCellValue("COL20");
    rowhead.createCell((short) 20).setCellValue("COL21");
    rowhead.createCell((short) 21).setCellValue("COL22");
    rowhead.createCell((short) 22).setCellValue("COL23");
    rowhead.createCell((short) 23).setCellValue("COL24");
    rowhead.createCell((short) 24).setCellValue("COL25");
    rowhead.createCell((short) 25).setCellValue("COL26");
    rowhead.createCell((short) 26).setCellValue("COL27");
    rowhead.createCell((short) 27).setCellValue("COL28");
    rowhead.createCell((short) 28).setCellValue("COL29");
    rowhead.createCell((short) 29).setCellValue("COL30");
    int index=1
    String name="";
    while(rs.next())
    System.out.println("Inside while");
    HSSFRow row = sheet.createRow((short)index);
    row.createCell((short) 0).setCellValue(rs.getString(2));
    row.createCell((short) 1).setCellValue(rs.getString(3));
    row.createCell((short) 2).setCellValue(rs.getString(4));
    row.createCell((short) 13).setCellValue(rs.getFloat(5));
    row.createCell((short) 4).setCellValue(rs.getString(6));
    row.createCell((short) 5).setCellValue(rs.getString(7));
    row.createCell((short) 6).setCellValue(rs.getInt(8));
    row.createCell((short) 7).setCellValue(rs.getString(9));
    row.createCell((short) 8).setCellValue(rs.getString(10));
    row.createCell((short) 9).setCellValue(rs.getString(11));
    row.createCell((short) 10).setCellValue(rs.getString(12));
    row.createCell((short) 11).setCellValue(rs.getFloat(13));
    row.createCell((short) 12).setCellValue(rs.getFloat(14));
    row.createCell((short) 13).setCellValue(rs.getFloat(15));
    row.createCell((short) 14).setCellValue(rs.getFloat(16));
    row.createCell((short) 15).setCellValue(rs.getFloat(17));
    row.createCell((short) 16).setCellValue(rs.getFloat(18));
    row.createCell((short) 17).setCellValue(rs.getFloat(19));
    row.createCell((short) 18).setCellValue(rs.getFloat(20));
    row.createCell((short) 19).setCellValue(rs.getFloat(21));
    row.createCell((short) 20).setCellValue(rs.getFloat(22));
    row.createCell((short) 21).setCellValue(rs.getString(23));
    row.createCell((short) 22).setCellValue(rs.getString(24));
    row.createCell((short) 23).setCellValue(rs.getString(25));
    row.createCell((short) 24).setCellValue(rs.getString(26));
    row.createCell((short) 25).setCellValue(rs.getString(27));
    row.createCell((short) 26).setCellValue(rs.getString(28));
    row.createCell((short) 27).setCellValue(rs.getString(29));
    row.createCell((short) 28).setCellValue(rs.getString(30));
    index++;
    rs.close();
    FileOutputStream fileOut = new FileOutputStream(filename);
    hwb.write(fileOut);
    fileOut.close();
    connection.close();
    catch(Exception e)
    System.out.println(e.getMessage());
    e.printStackTrace();
    Thanks in advance,
    Venky
    Edited by: Venky_86 on Apr 15, 2009 12:06 AM

    Its is an obvious thing...POI is known to need a lot of memory (the reason for that is most likely the OLE document format, which is quite complex).
    I would have used something like the below to see if that can address my client's requirement.
    public exportExcel(String fileName){
       Connection connection = null;
       Statement statement = null;
       ResultSet rs = null;
       PrintWriter out = null;
       int index=1;
       try{
         out = new PrintWrite(new FileWriter(fileName));
         connection = DbUtils.getConnection();
         statement = connection.createStatement();
         rs = statement.executeQuery("select * from Myschema.myfile");
         out.prinln("<table>");
         out.println("<th>COL1</th>");
         out.println("<th>COL2</th>");
         out.println("<th>COL3</th>");
         out.println("<th>COL4</th>");
         out.println("<th>COL5</th>");
         out.println("<th>COL6</th>");
         out.println("<th>COL7</th>");
         out.println("<th>COL8</th>");
         out.println("<th>COL9</th>");
        out.println("<th>COL30</th>");
         out.println("<thead>");
         out.println("<tbody>");
         while(rs.next()){
              out.println("<td>"+index+"</td>");
              out.println("<td>"+rs.getString(2)+"<td>");        
              out.println("<td>"+rs.getString(3)+"<td>");        
              out.println("<td>"+rs.getString(4)+"<td>");        
              out.println("<td>"+rs.getString(5)+"<td>");        
              out.println("<td>"+rs.getString(6)+"<td>");        
              out.println("<td>"+rs.getString(7)+"<td>");        
              out.println("<td>"+rs.getString(8)+"<td>");        
              out.println("<td>"+rs.getString(9)+"<td>");        
              out.println("<td>"+rs.getString(30)+"<td>");        
         out.println("</tbody>")     
         out.println("</table>");    
         out.flush(); 
       }catch(Exception exp){
           exp.printStackTrace();
       }finally{
           if(out != null)
            try{out.close();}catch(Exception e){}
             if(rs != null)
               try{rs.close();}catch(Exception e){}
            if(statement != null)
               try{statement.close();}catch(Exception e){}
             if(connection != null)
               try{connection.close();}catch(Exception e){}
    }and you can simply export the file using the method
    ApplicationUtils.getInstance().exportExcel("c:/export/myapp/ApplicationTable.xls");If you are using Office 2000 and above you should able open it as an excel worksheet without any problems.
    Hope that help :)
    REGARDS,
    RaHuL

  • Uploading a file using jsp and com.oreilly.servlet lib package

    Sorry to bother you but I need your help folks
    I am developing an application to pick up files from a database and sent to a specified location on a different system.
    I am presently trying to run this code,I have placed this lib package from oreilly which is supposed to encapsulate the usage of file uploads,which is a jar file called cos.jar into C:\Program Files\Java\jdk1.5.0_03\jre\lib\ext folder .I have a jsp page that calls the bean which does the upload and implement the classes in the oreilly package.I am using tomcat 5
    [b]the jsp page that acts as the user interface
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Please Choose The File</title>
    </head>
    <body bgcolor="#ffffff">
    <table border="0"><tr>
    <form action="Upload.jsp" method="post"
    enctype="multipart/form-data">
    <td valign="top"><strong>Please choose your document:</strong><br></td>
    <td> <input type="file" name="file1">
    <br><br>
    </td></tr>
    <tr><td><input type="submit" value="Upload File"></td></tr>
    </form>
    </table>
    </body>
    </html>
    this is the jsp page that calls the bean
    <jsp:useBean id="uploader" class="com.UploadBean" />
    <jsp:setProperty name="uploader" property="dir" value="<%=application.getInitParameter(\"save-dir\")%>" />
    <jsp:setProperty name="uploader" property= "req" value="${pageContext.request}" />
    <html>
    <head><title>file uploads</title></head>
    <body>
    <h2>Here is information about the uploaded files</h2>
    <jsp:getProperty name="uploader" property="uploadedFiles" />
    </body>
    </html>
    [b]this is the bean class
    package com;
    import java.util.Enumeration;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.ServletRequest;
    import com.oreilly.servlet.MultipartRequest;
    import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;
    import javax.servlet.*;
    public class UploadBean {
    private String webTempPath;
    private HttpServletRequest req;
    private String dir;
    // private ServletRequest request;
    public UploadBean( ) {}
    public void setDir(String dirName) {
    if (dirName == null || dirName.equals(""))
    throw new IllegalArgumentException("invalid value passed to " + getClass( ).getName( )+".setDir");
    //webTempPath = dirName;
    dir = dirName;
    /* public String getDir()
    return webTempPath;
    public void setReq(ServletRequest request) {
    if (request != null && request instanceof HttpServletRequest)
    req = (HttpServletRequest) request;
    } else {
    throw new IllegalArgumentException("Invalid value passed to " + getClass( ).getName( )+".setReq");
    public String getUploadedFiles( ) throws java.io.IOException{
    //file limit size of 5 MB
    MultipartRequest mpr = new MultipartRequest(req,dir,5 * 1024 * 1024,new DefaultFileRenamePolicy( ));
    Enumeration enume = mpr.getFileNames( );
    StringBuffer buff = new StringBuffer("");
    for (int i = 1; enume.hasMoreElements( );i++){
    buff.append("The name of uploaded file ").append(i).append(" is: ").append(mpr.getFilesystemName((String)enume.nextElement( ))).append("<br><br>");
    }//for
    //return the String
    return buff.toString( );
    } // getUploadedFiles
    On running the code I find this error messages
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: javax/servlet/ServletRequest
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
         org.apache.jsp.jsp.Upload_jsp._jspService(org.apache.jsp.jsp.Upload_jsp:73)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
         com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:222)
         com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:151)
         com.UploadBean.getUploadedFiles(UploadBean.java:49)
         org.apache.jsp.jsp.Upload_jsp._jspService(org.apache.jsp.jsp.Upload_jsp:63)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
    Apache Tomcat/5.5.9
    tanks

    Hi,
    Looks like you are missing a file from the classpath. Make sure servlet.jar is available in your classpath. Ordinarily files in <tomcat_home>/lib directory should be added automatically. You need to check why it hasn't been added in your case. A good place to start would be the bat files in the bin directory viz startup.bat, catalina.bat etc.
    cheers,
    vidyut

  • How to use jsp:plugin type="applet" in jsp

    Hi ,
    I have a JSP File.
    How to use jsp:plugin tag in that.
    When I specify the file name in code="applet.class" Then it is giving an error saying that It could not find the class.
    What is the solution for this.

    its not working.. it shows exception class not found exception.
    i have placed the jsp and applet class in the same folder. but its not working.
    jsp file path : OracleSpatial\mypackage\webmap.jsp
    applet class : OracleSpatial\mypackage\demoApplet.class
    demoApplet class inside package "mypackage".
    code inside JSP is :
    <jsp:plugin type="applet"
    code="mypackage.demoApplet.class" width = "100%" height = "100%" >
    </jsp:plugin>

Maybe you are looking for

  • Create a group based on file contents

    Hello! I'm investigating options to create a dynamic group based on periodic check of file content. I have a Shavlik updater which is patching custom groups based on file contents. I would like to create a dynamic group which should return all Window

  • Archivability check?

    I am trying to use SARA to archive Vendor (FI_ACCPAYB) and customer (FI_ACCRECV) master data and I want to know what checks the system uses to determine if a record is archivable. For example does it check that there are no transactions in the system

  • Need help troubleshooting WRT54G internet problem

    Recently in order to reconfigure my linksys router WRT54GL, i had to do a factory reset because of password problems. Then i logged in and set it to PPPoE (as usual), and ever since the internet has been completely erratic. I have this far used only

  • Lightroom not printing correct size image

    I am finding that my Lightroom 5 prints are bigger than the settings that I input in the Print module.  Can anybody tell me what I am doing wrong?

  • OSD Task Sequence Fails with Error 0x80091007

    Hello Everyone, I have a bit of a weird hash mismatch problem.  The issue is only occuring on one laptop.  The laptop was imaged successfully, new out of the box.  Computer started "acting craptacular" according to the tech, so he tried to reimage it