JSP problem

Hello,
I have a problem regarding jsp.
I have a html page called performance.html which has a link to month.jsp page.
When the user enters Number 1, Number 2 into the text boxes in the jsp page and click submit, it must be displayed on the 1st month colum of the table in performance.html page. (one under the other)
Give your sugessions on how to write the jsp code to implement the above.
Here is my code.
Performance.html
<form method="POST" action=" ">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="25%"> </td>
<td width="25%">1st month</td>
<td width="25%">2nd month</td>
</tr>
<tr>
<td width="25%">Number 1</td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
<tr>
<td width="25%">Number 2</td>
<td width="25%"> </td>
<td width="25%"> </td>
</tr>
</table>
<p> </p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
month.jsp
<form method="POST" action="PrintToTable.jsp">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="44%" id="AutoNumber1">
<tr>
<td width="19%">Number 1</td>
<td width="19%"> </td>
<td width="17%"><input type="text" name="T1" size="10"></td>
</tr>
<tr>
<td width="19%">Number 2</td>
<td width="19%"> </td>
<td width="17%"><input type="text" name="T2" size="10"></td>
</tr>
</table>
<p> </p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
Please help me.

month.jsp submits PrintToTable.jsp - what is PrintToTable.jsp suppose to do?

Similar Messages

  • Help me to solve this Jsp problem

    //Class1.java
    package p1.p2;
    public class Class1 implements Serializable
    private String name1,name2;
    public void setName1(String name)
    name1=name;
    public String getName1()
    return name1;
    public void setName2(String name)
    name2=name;
    public String getName2()
    return name2;
    //Class2.java
    package p1.p2;
    public class Class2
    String name1,name2;
    public String insert(Class1 c1)
    name1 = c1.getName();
    name2 = c2.getName();
    return name1;
    //Class3.jsp
    <%@ page import="p1.p2.*" %>
    <html>
    <form action="/bobby/Class3.jsp" method=post>
    Name1 : <input type=text name="cn1">
    Name2 : <input type=text name="cn2">
    <input type=submit value="Click"/>
    </form>
    </html>
    <%! String a,b,c; %>
    <%
    Class1 c1 = new Class1();
    Class1 c2 = new Class2();
    a=request.getParameter("cn1");
    b=request.getParameter("cn2");
    c1.setName(a);
    c1.setName(b);
    c=c2.insert(c1);
    out.println(c);
    %>
    WHEN I RUN THE JSP PROGRAM I GOT THE FOLLOWING ERROR.TELL ME THE SOLUTION TO SOLVE THIS PROBLEM.
    javax.servlet.ServletException:
    p1.p2.Class2.insert(Lp1/p2/Class1;)Ljava/lang/String;
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl .java:825)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.j ava:758)
    org.apache.jsp.Class3_jsp._jspService(Class3_jsp.java:76)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    root cause
    java.lang.NoSuchMethodError: p1.p2.Class2.insert(Lp1/p2/Class1;)Ljava/lang/String;
    org.apache.jsp.Class3_jsp._jspService(Class3_jsp.java:67)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

    First, please put your code inside code tags. There's a nice little button. All you have to do is paste your code, highlight it and press the little code button. Thanks.
    I had to make some adjustments to your original post. Either you had some closing braces in the wrong place, or you hve no idea what you're doing. I'm going to assume that Class1 is in a file named p1/p2/Class1.java and Class2 is in p1/p2/Class2.java.
    //Class1.java
    package p1.p2;
    public class Class1 implements Serializable
        private String name1,name2;
        public void setName1(String name)
            name1=name;
        public String getName1()
            return name1;
        public void setName2(String name)
            name2=name;
        public String getName2()
            return name2;
    //Class2.java
    package p1.p2;
    public class Class2
        String name1,name2;
        public String insert(Class1 c1)
            name1 = c1.getName();
            name2 = c2.getName();
            return name1;
    //Class3.jsp
    <%@ page import="p1.p2.*" %>
    <html>
    <form action="/bobby/Class3.jsp" method=post>
    Name1 : <input type=text name="cn1">
    Name2 : <input type=text name="cn2">
    <input type=submit value="Click"/>
    </form>
    </html>
    <%! String a,b,c; %>
    <%
        Class1 c1 = new Class1();
        Class1 c2 = new Class2(); //<-- problem here, do you see it?
        a=request.getParameter("cn1");
        b=request.getParameter("cn2");
        c1.setName(a);
        c1.setName(b);
        c=c2.insert(c1);
        out.println(c);
    %>Note the I highlighted the problem above. HTH.

  • JSP problem after PDF Form Submit

    Hi,
    Our project team is using a PDF with Acrobat Form fields behind it to post form data to a java servlet, where it is parsed and written to a legacy system.
    Our problem: when we return a jsp confirmation page back to the user, we are getting intermittent responses - sometimes the user will see the page, sometimes not. Also of note - the URL address location in the browser is being changed to "C://TEMP/xxxxxx.html", instead of showing "http://myserver/myapp/confirmPage.jsp". In effect, it doesn't retain the server location from which the form data was submitted - instead, after the jsp on that server is rendered into html, it is being written to a temp location on the local hard drive as an .html page, then displayed from there.
    In my debug testing, I have bypassed the bulk of my application code, submitting into the servlet and returning the jsp right back to the user. It works properly when submitted from an HTML page, but goes to the C://TEMP... route when submitted from the PDF. Therefore, I can conclude that the bug is not in our java code and is not in the jsp code.
    On our PDF we are using an Adobe script submitForm() function, naming our servlet to send to (without appending #FDF on it) and specifying "false" as our second parameter, since we are passing the data as an HttpRequest instead of as FDF data.
    I suspect the problem may be caused by some differences in the headers in the HttpRequest object coming from the PDF. In comparing the Request headers from the PDF submit and those from an HTML page submit:
    From the PDF:
    content-type = application/x-www-form-urlencoded
    user-agent = Mozilla/4.0 (compatible; Adobe Acrobat Control Version 5.00 for ActiveX)
    From an HTML submit:
    content-type = text/html
    user-agent = Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
    I have tried explicitly setting the headers to match those coming in from an HTML submit but this doesn't seem to make a difference.
    Has anyone experienced a similar problem? Any thoughts?
    jander

    This is a bug from Acrobat !
    The turnover is to send a FDF document with the file tag (/F) referencing the jsp page you want to display

  • Xml/html to jsp - problem with quotes in attribute values

    I am trying to convert a static html document into a jsp using an xsl stylesheet, but run into problems trying to use the jsp expression syntax inside of attribute values.
    Here is a sample of the source file:
    <input type="text" name="firstName" value=""/>
    Here is what I want the resulting jsp file to look like:
    <input type="text" name="firstName" value="<jsp:expression>customer.getField("firstName") </jsp:expression>">
    Here is what part of my stylesheet looks like:
    <xsl:template match="input">
    <xsl:copy>
    <xsl:copy-of select="@type"/>
    <xsl:copy-of select="@name"/>
    <xsl:attribute name="value">
    <xsl:text disable-output-escaping="yes"><jsp:expression></xsl:text>
    <xsl:text disable-output-escaping="yes">customer.getField(</xsl:text>
    <xsl:text disable-output-escaping="yes">"</xsl:text>
    <xsl:value-of select="@name"/> ")
    <xsl:text disable-output-escaping="yes">")</xsl:text>
    <xsl:text disable-output-escaping="yes"></jsp:expression></xsl:text>
    </xsl:attribute>
    </xsl:copy>
    </xsl:template>
    The problem i have is with the <%= customer.getField("firstName") %>. I have tried several different ways of inserting the double quotes around firstName, but no matter what I try, it always uses the entity reference instead of actually putting the " character. The jsp container will not accept the entity.
    I am assuming that the problem is with trying to place double quotes inside of an attribute value. Any ideas how to get around this?
    Thanks
    David

    Which App Server are you using?
    You should just be able to escape the double quotes.
    If that doesn't work, it's a bug in the app-server.
    Alternatively, you can use single quotes around the
    attribute value.
    Hope that helps,
    AlexSorry, I'm an idiot. By escaping you meant the unicode character escape "\u0022". I had not tried that. However, once i realized what you meant, I tried it, and it worked. Thanks for your help.
    David

  • Iplanet webserver 4.1 JSP problem

    Hi I am using iplanet webserver 4.1, whenever i change my jsp file, i have to restart my webserver instance otherwise ia gm getting error..is ther any way i can prevent to restart the webserver?

    this is the script.
    mv /logs/https-`uname -a`-443/access /logs/https-`uname -a`-443/access.yesterday
    compress /logs/https-`uname -a`-443/access.yesterday
    /opt/netscape/server4/https-`uname -a`-443/restart
    the moving and compressing works properly but the restart command doesn't actually kill the and restart the httpd process, and doesn't create the access or error log.
    The restart is a graceful restart will not ask for password, the same setting was working fine for a long time. it suddenly started to give this problem.
    the webserver is working fine(taking requests ,etc) except that the log files are not being written.
    i did a truss and the data collected is above i see that it is giving error #91 ERESTART many times
    there is another server with same settings which is working fine the only difference is that its patch level is lower.

  • Servlet/jsp problem

    hello i am using netbeans to create a simple login system using a servlet and a jsp. the jsp has the following code:
    <form action="login" method="get">
    <br>UserID <input type="text" name="userID" size="20" maxlength="20">
    <br>Password <input type="password" name="password" size="20" maxlength="20">
    <br><input type="submit" value="Login">
    </form>
    the servlet name is login and located under src/java/login.java
    however when i run it its just giving me this msg that it cannot find the servlet:
    type Status report
    message Servlet login is not available
    description The requested resource (Servlet login is not available) is not available.
    does anyone know what the problem might be?

    How have you defined this servlet in your web.xml ?
    For example it should be something like this:
        <servlet>
            <servlet-name>SomeServletAlias</servlet-name>
            <servlet-class>servletpackagename.ServletClassName</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>SomeServletAlias</servlet-name>
            <url-pattern>/servleturlpattern</url-pattern>
        </servlet-mapping>If you have the URL Pattern as: /servleturlpattern , then in your form's action put action="/servleturlpattern" and not action="servleturlpattern"
    Where ever you reference the servlet, the URL for the servlet should match exactly as you specify it in the URL-Pattern. Otherwise it wont work.

  • JDeveloper 3.1 and JSP problems

    Hello everybody.
    I present myself. I am a French student in computer sciences who makes a training course in a French company. (You will excuse the bad quality of my English)
    I have some difficulties in the use of Oracle JDeveloper tool.
    1st problem:
    I encountered this problem during the creation of a JSP page for a simple Intranet application connected to an Oracle database.
    JDeveloper doesnt want to take into account the fact that one of my tables has two primary (composite) keys;(Each of these two keys is primary key of another table). That results on the one hand in an error during the loading of the default edition form (" JBO-25030: Failed to find or invalidate owning entity ") and in addition by impossibility of consulting the recordings of this table according to one of the two key parameters (selected in RowSetBrowser). Nevertheless, this last aspect works within the Oracle Business Component Browser.
    2nd problem:
    Imagine, for example, the following simplified conceptual diagram:
    Racks ---> Files ---> Sheets (they are tables)
    How on a JSP page, can I display in the easiest way (with a JSNavigatorTab and a RowSetBrowser), the recordings of the table Sheets of a particular File, without to use a selection at the table Racks level.
    (You choose directly, with a ComboBox or a RowSetBrowser, a File to display all the corresponding Sheets, without to choose a Rack before.)
    In fact, I try to have an application as simple and ergonomic as possible.
    I thank all those who will be able to inform me on these obscure points which slow down my project considerably.
    Regards.
    Guillaume Vidal
    null

    Hi,
    * For your 1st problem, try to uncheck the "composite association" checkbox in the association object linking your tables together, should work better.
    * For the second one,
    when you create the application module containing the rack/file and sheet views, add the file view at root level (i.e do not use the view link relationship, which would include it as a detail view for the racks view), then add the sheet view through the file/sheet viewLink.
    This way you'll be able to browse the entire file and sheet list in a basic master/detail view.
    Good luck, Remi
    by Guillaume Vidal:
    Hello everybody.
    I present myself. I am a French student in computer sciences who makes a training course in a French company. (You will excuse the bad quality of my English)
    I have some difficulties in the use of Oracle JDeveloper tool.
    1st problem:
    I encountered this problem during the creation of a JSP page for a simple Intranet application connected to an Oracle database.
    JDeveloper doesnt want to take into account the fact that one of my tables has two primary (composite) keys;(Each of these two keys is primary key of another table). That results on the one hand in an error during the loading of the default edition form (" JBO-25030: Failed to find or invalidate owning entity ") and in addition by impossibility of consulting the recordings of this table according to one of the two key parameters (selected in RowSetBrowser). Nevertheless, this last aspect works within the Oracle Business Component Browser.
    2nd problem:
    Imagine, for example, the following simplified conceptual diagram:
    Racks ---> Files ---> Sheets (they are tables)
    How on a JSP page, can I display in the easiest way (with a JSNavigatorTab and a RowSetBrowser), the recordings of the table Sheets of a particular File, without to use a selection at the table Racks level.
    (You choose directly, with a ComboBox or a RowSetBrowser, a File to display all the corresponding Sheets, without to choose a Rack before.)
    In fact, I try to have an application as simple and ergonomic as possible.
    I thank all those who will be able to inform me on these obscure points which slow down my project considerably.
    Regards.
    Guillaume Vidal
    null

  • Please Urgent sound applet in jsp problem

    Hi please any body hekp me urgently.
    I have a problem while playing a sound applet in the jsp file the error is class not found.
    My applet class file is in the com.mypack.common
    its code is
    public class PlayErrorSoundApplet extends Applet
    public PlayErrorSoundApplet()
    public void init()
    public void playSound()
    String soundObj = getParameter("soundObj");
    AudioClip sound = getAudioClip(getDocumentBase(), "success.wav");
    sound.play();
    in the jsp i have written the code like this
    <applet codebase="com.mypack.common" code="PlayErrorSoundApplet.class" name="soundApplet" width="0" height="0">
    <param name="soundObj" value="error.wav">
    </applet>
    In the applet console i got class not found error.
    please help me .....advanced thanks......

    actually, codbase is a directory. so
    <applet codebase="com/mypack/common" code="PlayErrorSoundApplet.class" name="soundApplet" width="0" height="0">
    <param name="soundObj" value="error.wav">
    </applet>this means you have something like
    pacakge com.mypack.common
    public class PlayErrorSoundApplet {
    Make sure to put the html file in the root directory of the package structure
    /myhtmlfile.html
       /com
          /mypack
               /common
                    PlayErrorSoundApplet.class                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Custom tags in jsp - problems with import in java pgm

    Hi,
    I am new to JSP and am facing some problems.
    I am trying to compile the foll. java program and it is giving an error saying 1."Package javax.servlet.jsp does not exist", 2."Package javax.servlet.jsp.tagext does not exist".
    I am using 1.j2sdk1.4.1_02, 2.j2sdkee1.3.1,and 3.Tomcat 4.1
    My java_home=C:\j2sdk1.4.1_02
    j2ee_home=C:\j2sdkee1.3.1
    path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\j2sdkee1.3.1\bin;c:\j2sdk1.4.1_02\bin;c:\j2sdkee1.3.1\doc\api;c:\jakarta-ant-1.5.1\bin
    classpath=c:\j2sdkee1.3.1\bin;c:\j2sdk1.4.1_02\bin;c:\j2sdkee1.3.1\doc\api
    can anybody help me with it?
    Regards,
    newtojsp
    import java.io.IOException;
    import java.util.Date;
    import doc.api.javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    public class TestTag extends TagSupport
         public int doStartTag () throws JSPTagException
              String dateString = new Date().toString ();
              try
                   JspWriter out = page.context.getOut ();
                   out.println ("Welcome to the Loan Dept" + " <br>");
                   out.println ("Today is:" + dateString + "<br>");
                   return SKIP_BODY;
              } catch (IOException ee)
                   throw JspTagException ("Error Encountered");
         public int doEndTag () throws JSPTagException
              return EVAL_PAGE;

    I got the solution for this.
    Thanks
    Newtojsp

  • JSP PROBLEM...THEORETICAL QUESTION

    Hi as you all know by now im quite new to jsp and have struggled so far to get something decent working but now that i have im happy :D
    quick question for you all...
    imagine this scenario. when you submit an application for something...i.e. a job...your application status is 'pending' and when moved to the interview stage the status is changed to 'interview' and then if successful changes to 'job offer'
    these 3 'status' would be done as final int data types in java...ive done it before and thats not a problem. however how is one to approach that using jsp?? can it be done...if so, how??
    also when the user logs in to check the current status of his/her application they should be presented with this status either pending/interivew/job offer.
    any ideas??
    at the moment all i have done is an application submission which gets stored in an access database. i am nowworking on the part which manipulates the submitted applications according to criteria
    thanks!

    Level_ID Level_Name
    0 Pending
    1 Interview
    2 Offer
    3 Rejection
    how would i make a user who logs in to see his status
    as the word pending rather than 0?? i.e. how can i
    point the Level_ID in Login_Details table to find its
    corresponding Level_Name in the Levels table?Create a HashMap at init of your Main Servlet that is populated by this data, keyed by Integer. Make this table reloadable via an HTTP call, that way if you want to update the names you can do so without needing to restart your webserver.
    Then when its time to show the name, rather than the number, do :
    <%= servlet.statusTable.get( new Integer( user.getStatus() ) ) %>
    Probably would be a good idea to put this into a method so you can verify that the object exists, etc., call it showStatus(user)

  • Paper Layout in Report JSP - problem with anchors

    Hi,
    I am using an anchor to connect two frames. The frames are vertically expandable and horizontally fixed. When I run the report (PDF) as an rdf, I receive no errors, however when running the same report as a JSP, I get the following error : 'Object can never fit in within....<frame-name>'.
    What could be the reason? Is it a bug?
    Thanks,
    Bharat

    hi,
    i've not heared about this particular issue, but i think it might be a good idea to open a tar with oracle support. it could be, that some properties get mixed up in your particular case when saving the report as JSP and therefore the RDF works and the JSP doesn't. it is certainly not a generic issue, otherwise we would have already heared about it.
    another idea would be to apply the latest patchset (9.0.2.2) that contains a lot of fixes and it might fix your problem as well.
    regards,
    philipp

  • Servlet/JSP problems with WL 4.51

    Hi all
              I have a set of Servlets and JSPs running on NewAtlanta's ServletExec
              servlet engine. I am currently porting them to WebLogic. I am facing a
              few problems. I do not want to change any of my HTML/JSP/Java files
              immediately. I want the same files to work in WL as it is. Pl help.
              1. The servlets in ServletExec used to be invoked as
              http://host/servlet/servletName. But in weblogic they are invoked
              as http://host/servletName. I tried registering the servlet names
              in weblogic.properties as
              weblogic.httpd.register.servlet/XServlet=com.foo.XServlet
              weblogic.httpd.initArgs.servlet/XServlet=param=value
              Now I can call this servlet as http://host/servlet/XServlet and so
              I dont have to change any html/JSP files. Will this cause any
              problems in the future?
              2. Since we used to run ServletExec on IIS, we created a virtual
              directory called /jsp in IIS under which we had all the html and
              JSP files. Our servlets will get the http requests, get data from
              database, put the results in session/request variables and dispatch
              it to appropriate JSP page. So, all our servlet code looks like
              this:
              RequestDispatcher dispatcher =
              getServletContext().getRequestDispatcher("/jsp/test.jsp");
              dispatcher.forward(request, response);
              How do I make this code work with WebLogic? Is there any way to
              create virtual directory and make it work like in IIS?
              Thanks for any help.
              shiv
              [email protected]
              

    You might try
              weblogic.httpd.register.jsp/*.jsp=weblogic.servlet.JSPServlet
              but a better/ easier way would be to just move all of your jsp files to a 'jsp'
              subdirectory beneath public_html
              -rrc
              Shiv Kumar wrote:
              > Hi all
              >
              > I have a set of Servlets and JSPs running on NewAtlanta's ServletExec
              > servlet engine. I am currently porting them to WebLogic. I am facing a
              > few problems. I do not want to change any of my HTML/JSP/Java files
              > immediately. I want the same files to work in WL as it is. Pl help.
              >
              > 1. The servlets in ServletExec used to be invoked as
              > http://host/servlet/servletName. But in weblogic they are invoked
              > as http://host/servletName. I tried registering the servlet names
              > in weblogic.properties as
              >
              > weblogic.httpd.register.servlet/XServlet=com.foo.XServlet
              > weblogic.httpd.initArgs.servlet/XServlet=param=value
              >
              > Now I can call this servlet as http://host/servlet/XServlet and so
              > I dont have to change any html/JSP files. Will this cause any
              > problems in the future?
              >
              > 2. Since we used to run ServletExec on IIS, we created a virtual
              > directory called /jsp in IIS under which we had all the html and
              > JSP files. Our servlets will get the http requests, get data from
              > database, put the results in session/request variables and dispatch
              > it to appropriate JSP page. So, all our servlet code looks like
              > this:
              >
              > RequestDispatcher dispatcher =
              > getServletContext().getRequestDispatcher("/jsp/test.jsp");
              > dispatcher.forward(request, response);
              >
              > How do I make this code work with WebLogic? Is there any way to
              > create virtual directory and make it work like in IIS?
              >
              > Thanks for any help.
              > --
              > shiv
              > [email protected]
              Russell Castagnaro
              Chief Mentor
              SyncTank Solutions
              http://www.synctank.com
              Earth is the cradle of mankind; one does not remain in the cradle forever
              -Tsiolkovsky
              

  • REPOST: JSP problems!!!

    Sorry about the repost,
    I have been trying to get my JSP to work all night but with no success. At the moment it outputs the total set of data which I presume means that my queries aren't being executed properly. They work fine when typed directly into MySQL. Can anyone see the problem?
    The methods that I am using and the jsp code are displayed below,
         public void roomsBooked(String arrivalDate, String departureDate) throws SQLException, Exception
              if (con != null)
                try
                  Statement checkBookings = con.createStatement();
                  String query = ("CREATE TEMPORARY TABLE roomsoccupied "
                        + "SELECT roombooked.room_id FROM roombooked, booking "
                        + "WHERE "
                        + "roombooked.booking_id = booking.booking_id "
                        + "AND "
                        + "booking.arrival_date <  '" + departureDate +"'"
                        + "AND "
                        + "booking.departure_date >  '" + arrivalDate +"'"
                 checkBookings.executeUpdate(query);
                catch (SQLException sqle)
                  error = ""+sqle;
                  throw new SQLException(error);
                catch (Exception e)
                              error = ""+e;
                              throw new Exception(error);
              else
                error = "Exception: Connection to database was lost.";
                throw new Exception(error);
    public ResultSet roomsAvailable() throws SQLException, Exception
              if (con != null)
                try
                  Statement checkAvailability = con.createStatement();
                  String query = ("SELECT rooms.room_no FROM rooms "
                        + "LEFT JOIN roomsoccupied ON rooms.room_no=roomsoccupied.room_id "
                        + "WHERE roomsoccupied.room_id IS NULL;"
                 rs = checkAvailability.executeQuery(query);
                catch (SQLException sqle) {
                  error = ""+sqle;
                  throw new SQLException(error);
                catch (Exception e) {
                              error = ""+e;
                              throw new Exception(error);
              else {
                error = "Exception: Connection to database was lost.";
                throw new Exception(error);
           return rs;
      }JSP PAGE
    <%
          javaBean.connect();
          String arrivalDate =  request.getParameter("ArrivalDate");
          String departureDate =  request.getParameter("DepartureDate");
          javaBean.roomsBooked(arrivalDate, departureDate);
          ResultSet rs = javaBean.roomsAvailable();
          while(rs.next())
          {  %> Room number <%= rs.getString(1) %>
           <P><% }
          javaBean.disconnect();
    %>

    Well here is the original code with the PreparedStatements,Looking at this code, I'd say you have to learn what PreparedStatements are for:
    try
        String sql = "CREATE TEMPORARY TABLE roomsoccupied "
                          + "SELECT roombooked.room_id FROM roombooked, booked, booking "
                          + "WHERE "
                          + "roombooked.booking_id = booking.booking_id "
                          + "AND "
                          + "booking.arrival_date <  ? "                           
                          + "AND "
                          + "booking.departure_date > ?";
        PreparedStatement roomsBooked = con.prepareStatement(sql);
        roomsBooked.setDate(1, arrivalDate);   // This is what I mean by letting PS escape the dates for you
        roomsBooked.setDate(2, departureDate);
        roomsBooked.execute();
        roomsBooked.close();
    } catch (SQLException sqle)
        sqle.printStackTrace();
        System.err.println("SQL state: " + sqle.getSQLState());
        System.err.println("SQL error: " + sqle.getErrorCode());
    I'm assuming that you're passing java.sql.Dates to the method.  That's what PreparedStatement will require.  I'm also assuming that the columns in that table are of type date.
    >
    The queries work fine when run directly on the command
    line into MySQL and I have used System.out.println
    statements which tell me that both methods execute.
    Which leads me to believe that the MySQL code in my
    methods just isn't being entered into MySQL properly
    which is why it is returning NULL.
    Maybe.  It's good that the queries run in the MySQL command shell, but your problem is the JDBC code.
    As far as the temporary table is concerned, one is
    created for each connection to the database and it's
    results depend on each users query, which is why it is
    a temporary table rather then a permanent one. The
    results of each users temporary table are then used by
    the second method to obtain the needed results which
    should then be output by the JSP.
    I'll bet this could be done with a JOIN or a VIEW instead of a temporary table.  Sounds like the sign of a bad design, IMO. - MOD

  • Arabic jsp problem

    Hi All
    I have problem with arabic encoding in jsp
    here is my problem
    I have jsp page and contains textfield
    user put some text and submit the page
    this text is compared with other text that read from text file
    if two texts are equal some message appears to user
    I have made sample project it works fin with English text
    but it fails with Arabic texts
    her is my sample code
    <%
        String txt=request.getParameter("txt");
        if(txt!=null){
           if(MyClass.test(txt)){
               out.println("values are equal");
           }else{
               out.println("values are not equal");
        %>and method test is static method from MyClass
    public static  boolean test(String x) throws FileNotFoundException, IOException{
            LineNumberReader reader=new LineNumberReader(new FileReader("c:\\test.txt"));
            String line=reader.readLine();
            return line.equals(x);
        }I have tried HTML metaTage with Arabic encoding -notworked-
    and also tried <%@page with Arabic encoding also not worked
    any help will be
    appreciated
    thanks

    You use a Reader without specifying an encoding there. So you are using the system's default encoding. Most likely this is an encoding that does not match the actual encoding of that file which contains Arabic characters.
    Change your code to use an InputStreamReader and specify the correct encoding.

  • Swing Applet in JSP: problem with fetching data from database

    i am facing a problem while fetching data from database using Swing Applet plugged in a JSP page.
    // necessary import statements
    public class NewJApplet extends javax.swing.JApplet {
    private JLabel jlblNewTitle;
    private Vector vec;
    public static void main(String[] args) {
    JFrame frame = new JFrame();
    NewJApplet inst = new NewJApplet();
    frame.getContentPane().add(inst);
    ((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
    frame.pack();
    frame.setVisible(true);
    public NewJApplet() {
    super();
    initGUI();
    private void initGUI() {
    try {
    this.setSize(542, 701);
    this.getContentPane().setLayout(null);
    jlblTitle = new JLabel();
    this.getContentPane().add(jlblTitle);
    jlblTitle.setText("TITLE");
    jlblTitle.setBounds(197, 16, 117, 30);
    jlblTitle.setFont(new java.awt.Font("Dialog",1,20));
    jlblNewTitle = new JLabel();
    this.getContentPane().add(jlblNewTitle);
    Vector vecTemp = getDBDatum(); // data fetched fm DB r stored here.
    jlblNewTitle.setText(vecTemp.get(1).toString());
    jlblNewTitle.setBounds(350, 16, 117, 30);
    jlblNewTitle.setFont(new java.awt.Font("Dialog",1,20));
    } catch (Exception e) {
    e.printStackTrace();
    }//end of initGUI()
    private Vector getDBDatum() {
    // fetches datum from oracle database and stores it in a vector
    return lvecData;
    }//end of getDBDatum()
    }//end of class
    in index.jsp page i have included the following code for calling this applet:
    <jsp:plugin type="applet" code="NewJApplet.class" codebase="applets"
    width="600" height="300">
    <jsp:fallback>Could not load applet...</jsp:fallback>
    </jsp:plugin>
    if i view it in using AppletViewer it runs perfectly and display the data in JLabel. (ie, both jlblTitle and jlblNewTitle).(ie, DATA FETCHES FROM db AND DISPLAYS PROPERLY)
    BUT IF I CLICK ON INDEX.JSP, ONLY jlblTitle APPEARS. jlblnNewTitle WILL BE BLANK(this label name is supposed to fetch from database)
    EVERY THING IS DISPAYING PROPERLY EXCEPT DATA FROM DATABASE!!!
    i signed the applet as follows :
    grant {
    permission java.security.AllPermission;
    Can any body help me to figure out the problem?

    This is the Swing Applet java code
    import java.awt.Dimension;
    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Vector;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.JScrollPane;
    import javax.swing.JApplet;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTree;
    import javax.swing.ScrollPaneConstants;
    import javax.swing.SwingConstants;
    public class HaiApplet extends javax.swing.JApplet {
         private JLabel     jlblTitle;
         private JLabel     jlblNewTitle;
         private Vector     vec;
         * main method to display this
         * JApplet inside a new JFrame.
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              NewJApplet inst = new NewJApplet();
              frame.getContentPane().add(inst);
              ((JComponent)frame.getContentPane()).setPreferredSize(inst.getSize());
              frame.pack();
              frame.setVisible(true);
         public HaiApplet() {
              super();
              initGUI();
         private void initGUI() {
              try {               
                   this.setSize(542, 701);
                   this.getContentPane().setLayout(null);
                        jlblTitle = new JLabel();
                        this.getContentPane().add(jlblTitle);
                        jlblTitle.setText("OMMS");
                        jlblTitle.setBounds(197, 16, 117, 30);
                        jlblTitle.setFont(new java.awt.Font("Dialog",1,20));
                        jlblTitle.setHorizontalAlignment(SwingConstants.CENTER);
                        jlblTitle.setForeground(new java.awt.Color(0,128,192));
                        jlblNewTitle = new JLabel();
                        this.getContentPane().add(jlblNewTitle);
                        Vector vecTemp = getDBDatum();
                        jlblNewTitle.setText(vecTemp.get(1).toString());
                        jlblNewTitle.setBounds(350, 16, 117, 30);
                        jlblNewTitle.setFont(new java.awt.Font("Dialog",1,20));     
              } catch (Exception e) {
                   e.printStackTrace();
         }//end of initGUI()
         private Vector getDBDatum() {
              Vector lvecData = new Vector(10,5);
              Connection lcon = null;
              Statement lstmt = null;
              ResultSet lrsResults = null;
              String lstrSQL = null;
              String lstrOut = null;
              try {
                   OmmsDBConnect db = new OmmsDBConnect();
                   lcon = db.connectDb();
                   lstmt = lcon.createStatement(lrsResults.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                   lstrSQL = "select DT_ID from P_DATATABLES";
                   lrsResults = lstmt.executeQuery(lstrSQL);        
                   int i = 0;
                   lrsResults.last();
                   int length = lrsResults.getRow();
                   System.out.println(length);
                   lrsResults.beforeFirst();
                   int recCount = 0;
                   while (lrsResults.next()) {
                        recCount++;
                        lvecData.addElement(new String(lrsResults.getString("DT_ID")));
                   //     System.out.println("ID :  " + lrsResults.getString(1));
                        i++;
                   }System.out.println("here 3 out fm while");
              catch(SQLException e) {
                   System.out.print("SQLException: ");
                   System.out.println(e.getMessage());
              catch(Exception ex) {
                   lstrOut = "Exception Occured " + ex.getMessage();
              finally {
                   try {
                        lrsResults.close();
                        lstmt.close();
                        lcon.close();
                        System.out.println("[DONE]");
                   catch(Exception e) {
                        System.out.println(e);
             }//end of finally
              return lvecData;
         }//end of getDBDatum()
    }//end of classOfcourse the above code compiles and runs well. in Applet Viewer
    I plugged the above Swing Applet in a JSP page index.jsp
    <jsp:plugin type="applet" code="NewJApplet.class" codebase="applets"
                   width="600" height="300">
         <jsp:fallback>Could not load applet...</jsp:fallback>
    </jsp:plugin>Every thing is working fine in AppletViewer...But if i view this in any browser, then only the jlblTitle is displaying. jlblNewTitle is not displaying(this label name is actually fetching from thedatabase)
    can any body help me regarding this matter.? Thx in Advance.

Maybe you are looking for

  • Problems with image on tablet and mobile.

    I'm animations with various types of images, and for some reason I am unaware the images do not load right. I realized that when doing a pinch zoom feature of the tablet getting her perfect fix. I tried png and svg. Both give the same problem.Someone

  • Rearranging Nodes in a JTree

    Hi all, I'm trying to imitate a bookmark folder, where users can rearrange their bookmarks by dragging a selected node to another location (in between nodes). Users can also drag a node to a folder node and it gets put in that folder node. I currentl

  • WebService databinding not proper

    Hi, I'm totally new to Flashbuilder so bare with me. It seems this is not working properly. If the webservice returns more than one field the results will not display in a datagrid, its blank. If I change the webservice to only return one field that

  • Flash 8 crashes

    flash 8 crashes. I increase my windows outer windows border thickness in display options win2000. then click just to the left of the word colors underneath the magnifying glass icon in the Tool Bar and flash crashes all the time. Can this be fixed in

  • Push Not Working After Update to 2.1

    Using Mobile Me. Not sure if its a server problem. Additionally, I have fetch set for hourly and that does not appear to be working either.