Javabean problem in my jsp file .. help??

Hi to you all
please help me develope the login page to website, i m using the following code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" contentType="text/html" %>
<%-- Import the necessary Java classes --%>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.awt.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <jsp:useBean id="myLogin" scope="session" class="gugis.login" />
    <jsp:setProperty name="myLogin" property="admin_email" />
    <jsp:setProperty name="myLogin" property="admin_password" />
    <% String UID =%><jsp:getProperty name="myLogin" property="admin_email" /><%;%>
    <% String PWD =%><jsp:getProperty name="myLogin" property="admin_password" /><%;%>
    <%
            String query = "SELECT * FROM User WHERE Email = '" + UID + "' AND Password = '" + PWD + "'";
            String username_1 = new String();
            String password_1 = new String();
            String FN = new String();
            String SN = new String();
            try {
                //load the ODBC JDBC driver
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                //open a connection to the "gugis" database
                Connection con = DriverManager.getConnection("jdbc:odbc:gugis", "", "");
                //create a statement object for sending SQL queries
                Statement stmt = con.createStatement();
                //place query results in a ResultSet object
                ResultSet res = stmt.executeQuery(query);
                //assign ResultSet's column 4 & 5 to a String variable
                while (res.next()) {
                    username_1 = res.getString("Email");
                    password_1 = res.getString("Password");
                //clean up all objects
                res.close();
                stmt.close();
                con.close();
                if (!UID.equals(username_1) && !PWD.equals(password_1)) {
                    response.sendRedirect("Error.jsp");
                } else if (UID.equals("") || PWD.equals("")) {
                    response.sendRedirect("Error.jsp");
                } else if (UID.equals(null) || PWD.equals(null)) {
                    response.sendRedirect("Error.jsp");
                } else if (UID.equals(username_1) && PWD.equals(password_1)) {
                    response.sendRedirect("admin.jsp");
            } catch (ClassNotFoundException err) {
                out.println("USERNAME and PASSWORD does not exist in our database...");
    %>
  </body>
</html>but i am having error on the following code
<% String UID =%><jsp:getProperty name="myLogin" property="admin_email" /><%;%>
<% String PWD =%><jsp:getProperty name="myLogin" property="admin_password" /><%;%>
or I am doing it wrong, please advise how to implement the secure code
i m try to acheve the follwoing
1 user login with username and password on index,jsp page and when login button been pressed it go to admin_login.jsp file which check that user exist in database then redirect to the correct page ( error or admin)
2 I do not want to display username and password in ADDRESS BAR, but in my code its displaying .. so help on this issue as well
Regards
Gugi
Edited by: gugi_sat on 20-Aug-2008 21:54

<%-- Import the necessary Java classes --%>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.awt.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>Most of those classes are not necessary.
java.lang is ALWAYS imported.
java.awt can't be used on a jsp page.
javax.servlet is automatically imported in a jsp.
the only one you actually need from there is java.sql.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" contentType="text/html" %>
<%-- Import the necessary Java classes --%>
<%@ page import="java.sql.*" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <jsp:useBean id="myLogin" scope="session" class="gugis.login" />
    <jsp:setProperty name="myLogin" property="admin_email" />
    <jsp:setProperty name="myLogin" property="admin_password" />
<%
    String UID =myLogin.getAdmin_email();
    String PWD = myLogin.getAdmin_password()
            String query = "SELECT * FROM User WHERE Email = ? AND Password = ?";
            Connection con = null;
            PreparedStatement stmt = null;
            ResultSet res = null;
            try {
                //load the ODBC JDBC driver
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                //open a connection to the "gugis" database
                con = DriverManager.getConnection("jdbc:odbc:gugis", "", "");
                //create a statement object for sending SQL queries
                stmt = con.prepareStatement(query);
                //place query results in a ResultSet object
                stmt.setString(1, UID);
                stmt.setString(2, PWD);
                res = stmt.executeQuery();
                if (res.next()) {
                    // found username/password == success
                    out.println("You have logged in successfully");
                else {
                   // no results from query == failed to find username/password
                   out.println("USERNAME and PASSWORD does not exist in our database...");
            } catch (ClassNotFoundException err) {
                out.println("Error locating database driver...");
              catch (SQLException err) {
                out.println("Error running query...");
            finally {
                 //clean up all objects
                try { if (res != null) res.close(); } catch(SQLException ex){}
                try { if (stmt != null) stmt.close();} catch(SQLException ex){}
                try { if (con != null) con.close();} catch(SQLException ex){}
    %>
  </body>
</html>Ok changes made
1 - Replaced statement with PreparedStatement - protects from sql injection attack
2 - Your query is comparing the username/password. You don't need to check them in your program as well. If the query returns anything it WILL be the same username password. If the query returns no rows, then you didn't find that username, or you got the password wrong.
3 - Moved "cleanup" into a "finally" clause - makes sure it runs and releases connections if an exception occurs.
4 - cleaned up the imports - you weren't using half of them.
5 - removed unnecessary variables.
@Balusc: Just to note that the <jsp:useBean> tag creates a scriptlet variable on the page. It is preferable to use that than to retrieve and cast it from the session IMO.
Cheers,
evnafets

Similar Messages

  • Ergent problem with the jsp file access in tomcat. HELP...

    I use tomcat as my server, I have one JSP file located in :
    webapps\abc\war\WEB-INF\jsp\index.jsp
    You see my project name is abc, I want to access the index.jsp file, I define another jsp file in the path: webapps\abc callled outside.jsp. I want to use outside.jsp to invoke the index.jsp.
    Inside outside.jsp it is :
    <html>
    <head>
    <title>index</title>
    </head>
    <body>
    <%@ include file="war/WEB-INF/jsp/index.jsp" %/>
    </body>
    </html>
    When I open the browser, and access, http://localhost:8080/abc/outside.jsp , the content of index.jsp was shown as expect. But, all the link pages of the index.jsp can not shown (PS: the link pages is located in the same path as index.jsp, they are all jsp files). I guess the problem may be that the <%@ include file="war/WEB-INF/jsp/index.jsp" %/> inside outside.jsp include the index.jsp as a static file. Is there any method to make all the link pages of index.jsp can be shown when call from outside.jsp???HELP
    Message was edited by:
    Mellon
    Message was edited by:
    Mellon

    I don't know why your links can't be shown, but I can tell you that your suspect:
    I guess the problem may be that the <%@ include file="war/WEB-INF/jsp/index.jsp" %/> inside outside.jsp include the index.jsp as a static file.is wrong, because included jsp is dynamic, not static.

  • Errors in JSP files, help.....

    I have 2 questions:
    1)
    When i javac a java file, the following errors came out.
    C:\>javac logon.java
    logon.java:3: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    logon.java:4: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    2 errors
    Anyone knows what does it means??? Any ways to solve this error??
    2)
    When i type http://localhost:8080/cdlist/cd_list.jsp at the IE address to view the file , the following error came out
    org.apache.jasper.JasperException: This absolute uri (http://jakarta.apache.org/taglibs/xtags-1.0) cannot be resolved in either web.xml or the jar files deployed with this application
    Can anyone please explain what it means and is there any ways to solve this error. Thankyou very much....

    Sorry but there seems to have another problem, while i run the file using tomcat this error came out:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 40 in the jsp file: /processLogon.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\processLogon_jsp.java:153: ';' expected
                   routeURL = "frame.htm"
    ^
    An error occurred at line: 19 in the jsp file: /processLogon.jsp
    Generated servlet error:
    C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\processLogon_jsp.java:71: cannot resolve symbol
    symbol : class logon
    location: package logonBean
    logonBean.logon logon = null;
    ^
    An error occurred at line: 19 in the jsp file: /processLogon.jsp
    Generated servlet error:
    C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\processLogon_jsp.java:73: cannot resolve symbol
    symbol : class logon
    location: package logonBean
    logon = (logonBean.logon) pageContext.getAttribute("logon", PageContext.SESSION_SCOPE);
    ^
    An error occurred at line: 19 in the jsp file: /processLogon.jsp
    Generated servlet error:
    C:\jakarta-tomcat-4.1.18\work\Standalone\localhost\_\processLogon_jsp.java:76: cannot resolve symbol
    symbol : class logon
    location: package logonBean
    logon = (logonBean.logon) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "logonBean.logon");
    ^
    I was wondering, will tomcat javac the java file itself or do i need to javac it myself and put it in the root folder??? In this case i have javac the java file and i put the class file in root folder together with other files to run it, but there seems to still have errors while i try to run it. Pls help.

  • Problem in compiling jsp file

    Hi,
    i am using tomcat 4.12 and jdk 1.4.
    My login page contains 3 frames. after succesful login into ur application, 7 frames are getting called.
    i have called a jsp page for each frame.
    sometimes while accessing my application, i am getting jasper exception like cannot resolve symbol....
    for example
    D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sample\web\helpdesklogin_jsp.java:404: cannot resolve symbol
    symbol : method --ite  (java.lang.String)
    location: class javax.servlet.jsp.JspWriter
    out.write("<tr bgcolor=\"ffffff\">\r\n ");
    i do not understand the what is the problem here....
    likewise i am getting jasper exception. but it is not frequently occured in the frame.
    is there any relation with autoflush page directive attribute...?
    if it then should i increase default buffer size ?
    Reply please
    Thanks

    Your helpdesklogin.jsp file has a compilation error. It's hard to tell, but it looks like you mis-typed out.write() somewhere.
    - Saish

  • I have a problem getting my jsp file to display in the right way

    I have this dreamweaver htm page. i want to put the searchengine that shows happy home posibilities put next to the linked "happy home vakantiehuizen"
    or otherwise keep it in this spot but having the text being outlined next to the searchengine.
    I put the searchengine wher it is now with a divtag.
    I tried to put a layertable or layercell  within this layer but i am not able to do that.
    Does someone have a idea how to fix this???

    Hold the keyboard button down for a second or two and hit the Dock button when it pop up
    http://i1224.photobucket.com/albums/ee374/Diavonex/d5ea89bc.jpg

  • Jsp and JavaBean problem

    Hi All,
    I need UR help
    Problem:
    I have a javaBean and a jsp page say test.class and test.jsp respectively.
    Now the problem is when i run my jsp in web browser with path
    http://localhost:8080/mypackage/test.jsp and use test.class in it. It give me an error Class test.class Not Found but when i give the path http://localhost:8080/examples/jsp/parentpackage/mypackage/test.jsp
    it works fine.
    I am using Tomcat 3.2 and i have already made changes in server.xml for my jsp files thats why i can run my programs with the earlier path but dont know why its giving the error when i use javabean,
    Also i have put my javabean class in---parentpackage/mypackage/test.class
    Thanks
    Amit

    hi there,
    Thanks for you time, here i have placed the source for jsp and javabean
    Please excuse me if you find the code unproper
    Code for JSP:
    <%
    response.setHeader("Pragma","No-cache");
    response.setDateHeader("Expires",0);
    response.setHeader("Cache-control","No-cache");
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Internal Clarification-Agent View</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body background="images/c.jpg" bgproperties="fixed">
    <%@ page language="java" import="java.sql.*" %>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="java.util.*" session="true"%>
    <%@ page import="java.util.Date" %>
    <%@ page import="java.sql.Timestamp" %>
    <%@ page import="java.text.*" %>
    <%@ page import="java.lang.*" %>
    <%@ page import="javax.servlet.http.*"%>
    <jsp:useBean id="navi" class="arvato.interclarification.rqchunk" scope="session" />
    <%
    try{
    Connection con = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:interdsn","","");
    String qrno = request.getParameter("qrno");
    String rdb = request.getParameter("rb");
    String key = request.getParameter("key");
    String cname = request.getParameter("cname");
    //out.print(key);
    //if(st.equals("All")){
    String sql="";
    if(rdb!=null){
    if(rdb.equals("1")){
    if(qrno==null||qrno.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(qrno!=null){
    sql = "SELECT * FROM crequired WHERE queryno LIKE '"+qrno+"%'";
    }else if(rdb.equals("2")){
    if(key==null||key.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(key!=null){
    sql = "SELECT * FROM crequired WHERE clarification LIKE '"+key+"%'";
    else if(rdb.equals("3")){
    if(cname==null||cname.equals("")){
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    else if(cname!=null){
    sql = "SELECT * FROM crequired WHERE fname LIKE '"+cname+"%'";
    if(rdb==null)
    sql = "SELECT * FROM crequired ORDER BY adate DESC";
    ps = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    //ps.setString(1,space);
    /*}else{
    sql = "SELECT * FROM crequired WHERE status=? AND space=?";
    ps = con.prepareStatement(sql);
    ps.setString(1,st);
    ps.setString(2,space);
    ResultSet rs = ps.executeQuery();
    %>
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="50%"><strong><img src="images/microsoftlogo1.jpg" width="288" height="94"></strong></td>
    <td width="50%"><div align="right"><strong><img src="images/logo2.jpg" width="177" height="77"></strong></div></td>
    </tr>
    </table><br>
    <hr noshade color="#000000">
    <div align="center"><font color="#990000" size="4" face="Verdana, Arial, Helvetica, sans-serif"><strong>CSR
    VIEW</strong></font>
    </div>
    <form name="form" method="post" action="agentview1.jsp">
    <table width="59%" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td width="49%"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
    <input name="rb" type="radio" value="1" <%if(rdb!=null){if(rdb.equals("1")){out.print("checked");}}%>>
    <font size="1">SEARCH BY QUERY NUMBER:</font></strong></font></td>
    <td width="51%"><input name="qrno" type="text" id="qrno"></td>
    </tr>
    <tr>
    <td><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
    <input type="radio" name="rb" value="2" <%if(rdb!=null){if(rdb.equals("2")){out.print("checked");}}%>>
    <font size="1"> SEARCH BY KEY WORD:</font></font></strong></td>
    <td><input name="key" type="text" id="key"></td>
    </tr>
    <tr>
    <td><input type="radio" name="rb" value="3" <%if(rdb!=null){if(rdb.equals("3")){out.print("checked");}}%>>
    <strong><font size="1" face="Verdana, Arial, Helvetica, sans-serif">SEARCH
    BY CSR NAME:</font></strong></td>
    <td><input name="cname" type="text" id="cname"></td>
    </tr>
    <tr>
    <td colspan="2"><div align="center">
    <input type="submit" name="Submit" value="Submit">
    </div></td>
    </tr>
    </table>
    </form><br>
    Back
    <%
    navi.setchunk(10);
    navi.setRS(rs);
    String v="";
    String vv=request.getParameter("off");
    if(vv==null){v="1";}
    else{
    v=vv;
    int i=Integer.parseInt(v);
    navi.setcursor(i);
    ResultSet rs2=navi.getRS();
    int h1=1;
    if(request.getParameter("off")!=null) h1=Integer.parseInt(request.getParameter("off"));
    int h2= navi.getchunk();
    int h3= navi.getcount();
    int offset=(h3-h1)<h2?h3:(h1+h2-1);
    %>
    <table width=100%><tr><td width=33%> </td><td align=center width=34%><font face="verdana, arial" size=2 color=#000000>Displaying <%=h1%> to <%=offset%> of <font size=4><%=h3 %></font></font></td><td width=33%> </td></tr></table>
    <%
    int c1=navi.getcount(),c2=navi.getchunk();
    int c3=navi.getcursor();
    int c4=c3+c2;
    int c5=c3-c2;
    %>
    <table width=100% ><tr><td align=left width=100% >
    <%
    if(c3>c2 && c3<=c1){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c5+"\">Previous</a>");
    %></td><td align=right width=100%>
    <%
    if(c1>c2 && (c1-c3)>=c2){
    out.print("<a href=\"agentview1.jsp?n=y&off="+c4+"\">Next</a>");}
    %>
    </td></tr></table>
    <table width="1359" border="0" cellspacing="1">
    <tr bgcolor="#3C6C84">
    <th width="2%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">S.No.</font></th>
         <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Query No</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Posting Date & Time</font></th>
         <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Posted
    By</font></th>
    <th width="6%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Received
    By</font></th>     
    <th width="3%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Sub
    Process </font></th>
         <th width="4%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Region</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Status</font></th>     
    <th width="15%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Clarification
    Required OnQuery </font></th>
    <th width="18%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Solution</font></th>
    <th width="8%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Visited On</font></th>
    <th width="7%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Date
    & Time Closed On</font></th>
    <th width="5%"><font color="#FFFFFF" size="1" face="Verdana, Arial, Helvetica, sans-serif">Remarks</font></th>
    </tr>
    <%
    int m = 0;
    for(int l=0;l<c2 && i<=c1;l++,i++){
    //while(rs.next()){
    m = m+1;
    String queryno = rs.getString("queryno");
    //out.print(queryno);
    %>
    <tr>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=m%></b></font></td>
         <td width="5%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=queryno%></b></font></td>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <%Date d1 = rs.getDate("adate");
         String dd1="";
         SimpleDateFormat sddf = new SimpleDateFormat("MM/dd/yyyy");
         dd1 = sddf.format(d1);
         Date t1 = rs.getTime("atime");
         String tt1="";
         SimpleDateFormat stdf = new SimpleDateFormat("HH:mm");
         tt1 = stdf.format(t1);
         String ttm = dd1+" "+tt1;
         out.print(ttm);     
         %></font>
    </td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
    <b><%String fnm = rs.getString("fname");
    String lnm = rs.getString("lname");
    String nm = fnm+" "+lnm;
    out.print(nm);
    %></b></font></td>
    <td width="6%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         String tnm = rs.getString("tname");
         if(tnm.equals("null")||tnm.equals("-")){}else{out.print(tnm);}
         %></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%=rs.getString("space")%></b></font></td>
         <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><%String rg = rs.getString("region");
         if(rg==null||rg.equals("null")){}else{out.print(rg);}%></b></font></td>
         <%String status = rs.getString("status");
         if(status.equalsIgnoreCase("New")){%><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td>
         <%}else if(status.equalsIgnoreCase("Open")||status.equalsIgnoreCase("Awaiting MS Reply")){%><td bgcolor="#FFCC33"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}else{%><td bgcolor="#00CC00"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b><%=status%></b></font></td><%}%>
    <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#0000CC"><%=rs.getString("clarification")%></font></td>
         <%
    //String queryno = rs.getString("queryno");
    String qry1 = "select * from csolution where queryno=?";
    ps1 = con.prepareStatement(qry1);
    ps1.setString(1,queryno);
    ResultSet rs1 = ps1.executeQuery();
    while(rs1.next()){%>
    <td bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%=rs1.getString("solution")%></font></td>
         <td bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dp = rs1.getDate("dateofopen");
         String dp1="";
         SimpleDateFormat spdf = new SimpleDateFormat("MM/dd/yyyy");
         dp1 = spdf.format(dp);
         Date tp = rs1.getTime("timeofopen");
         String tp1="";
         SimpleDateFormat stpf = new SimpleDateFormat("HH:mm");
         tp1 = stpf.format(tp);
         String tpm = dp1+" "+tp1;
         out.print(tpm);
         %></font>
    </td>
         <td width="5%" bgcolor="#FFFFCC"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%
         Date dc = rs1.getDate("dateofclose");
         String dc1="";
         SimpleDateFormat scdf = new SimpleDateFormat("MM/dd/yyyy");
         dc1 = scdf.format(dc);
         Date tc = rs1.getTime("timeofclose");
         String tc1="";
         SimpleDateFormat stcf = new SimpleDateFormat("HH:mm");
         tc1 = stcf.format(tc);
         String tcm = dc1+" "+tc1;
         out.print(tcm);
         %></font>
    </td>
         <td width="16%" bgcolor="#FFE4CA"><font face="Verdana, Arial, Helvetica, sans-serif" size="1"><%String remarks = rs1.getString("remarks");
         if(remarks==null){}else{out.print(remarks);}
         %></font></td>
    <%}navi.setcursor();
    }con.close();}catch(Exception e){out.print(e);}%>
    </tr>
    </table><br>
    <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Back to
    Main Menu</font>
    </body>
    </html>
    Code for javaBean:
    package arvato.interclarification;
    import javax.servlet.http.*;
    import java.sql.*;
    public class rqchunk
              ResultSet rs=null;
              int chunk=5;
              int count=0;
              int cursor=1;
              public rqchunk(){}
              public void setRS(ResultSet rset) throws SQLException
                   rs = rset;
                   int cnt=0;
                   while(rs.next())
                        cnt++;
                   rs.absolute(1);
                   count=cnt;
              public void setcursor()throws SQLException
                   cursor++;
                   rs.absolute(cursor);
              public void setcursor(int i)throws SQLException
                   cursor=i;
                   rs.absolute(cursor);
              public int getcursor()
                   return cursor;
              public int getchunk()
                   return chunk;
              public void setchunk(int i)
                   chunk=i;
              public void setcount(int j)
                   count=j;
              public int getcount()
                   return count;
              public ResultSet getRS()
                   return rs;
              public void clearRS()
                   cursor=0;
                   rs=null;
    Please excuse me if my codes are not understandable enough
    Thanks
    Amit

  • JavaBeans Problems with JSP

    I am having some serious problems with getting a JSP to access a JavaBean that I have created. I am using Tomcat and Java 1.4 by the way.
    I have set my classpath and all other code continues to work apart from the accessing of the JavaBean. I have created a JavaBean which is as follows:
    public class UserData {
    String username;
    String email;
    int age;
    public void setUsername( String value )
    username = value;
    public void setEmail( String value )
    email = value;
    public void setAge( int value )
    age = value;
    public String getUsername() { return username; }
    public String getEmail() { return email; }
    public int getAge() { return age; }
    The class compiles no problem and I have placed it in the WEB-INF/Classes directory. However when I use the JSP to call it:
    <jsp:useBean id="user" class="UserData" scope="session"/>
    <jsp:setProperty name="user" property="*"/>
    <HTML>
    <BODY>
    Continue
    </BODY>
    </HTML>
    I get the following error:
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    An error occurred at line: 1 in the jsp file: /saveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\saveName$jsp.java:56: Class org.apache.jsp.UserData not found.
    UserData user = null;
    ^
    An error occurred at line: 1 in the jsp file: /saveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\saveName$jsp.java:59: Class org.apache.jsp.UserData not found.
    user= (UserData)
    ^
    An error occurred at line: 1 in the jsp file: /saveName.jsp
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\_\saveName$jsp.java:64: Class org.apache.jsp.UserData not found.
    user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
    ^
    3 errors, 1 warning
    I cannot work out as to why it is doing this. Any help at all would be really appreciated.
    Regards
    Ian

    Hi...
    Can you try making these changes...
    public class UserData {
    String username="";
    String email="";
    int age=0;
    public void setUsername( String value )
    this.username = value;
    public void setEmail( String value )
    this.email = value;
    public void setAge( int value )
    this.age = value;
    Regds
    Vasi

  • Help running a simple jsp file,Tomcat 5.0.16

    Hi,
    This question may be addressed many many times,but do reply.
    I have a Win xp operating system
    Installed Tomcat 5.0.16 in it.
    Next the directory structure
    PS : The sampleapp directory is outside the tomcat installation directory.
    E:/sampleapp
    | |
    ROOT WEB-INF
    |
    classes
    |
    <package1><structure> .class files (for servlet works fine!!!!)
    in the WEB-INF,there is the web.xml,then sourcefiles<dir> and the lib directory which is empty.
    Now the servlet files work fine.........
    I have placed my MyJsp.jsp file in the above mentioned ROOT directory.
    I have not done any thing with the <TOMCAT_HOME>/conf/server.xml file
    and the web.xml which I have written.
    When I give the following URI
    http://localhost:8080/sampleapp/MyJsp.jsp,
    I get the HTTP status 404- /MyJsp.jsp
    description: The requested resource (/MyJsp.jsp) is not available.
    Hoping that I have defined the problem specifically.Kindly show some light on this.
    Thanks
    AS

    Nevermind. I just found the answer. For the record, there are two ways in getting JSPs to work:
    1. Precompiling the JSPs and modifying your webapp's web.xml file with the XML fragment generated in YourWebApp/web/WEB-INF/generated_web.xml;
    2. Not precompiling the JSPs, but simply letting tomcat compile it on the fly on first access.
    PRECOMPILATION METHOD
    Go to http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jasper-howto.html. Copy-and-paste the ant script under the section "Web Application Compilation" into a file called compile.xml. For me, I save it in ~/development/compile.xml. Then compile the JSPs using the command (all in a single line):
    $ANT_HOME/ant -file <PATH_TO_COMPILE.XML> -Dtomcat.home=<$TOMCAT_HOME> -Dwebapp.path=<$WEBAPP_PATH>
    In my case, I cd into the directory where my app resides:
    cd ~/development/HelloWorld
    and then I type:
    ant -file ~/development/compile.xml -Dtomcat.home=/var/tomcat5 -Dwebapp.path=.
    (Note the trailing dot since my current directory is my webapp's directory itself. Also, in my case, my shell's PATH contains the path to the ant executable, so I just type 'ant' directly.)
    Open the file ~/development/HelloWorld/web/WEB-INF/generated_web.xml and follow the instructions in that auto-generated file, which is: "Place this fragment in the web.xml before all icon, display-name, description, distributable, and context-param elements."
    The web.xml referred to above is YOUR web.xml. In my case, it is the one in ~/development/HelloWorld/web/WEB-INF/web.xml
    When ready to deploy, type:
    ant dist
    as usual. Deploy the .war file in the dist directory as you normally would. In my case, I do:
    rm -rf $CATALINA_HOME/webapps/hello* (removes my HelloWorld webapp directory and its war file)
    cp ~/development/HelloWorld/dist/hello.war $CATALINA_HOME/webapps
    and wait for tomcat to unravel the war file. I can then access the JSP page based on whatever the generated_web.xml had specified. In my case, it would be http://localhost:8080/hello/sample.jsp
    NON-PRECOMPILATION METHOD
    Copy tools.jar from the Java JDK into tomcat's common/lib. (I found this only in the error message in tomcat's log file!! Didn't find it anywhere else!!). Do this one time only, then restart tomcat:
    cp $JAVA_HOME/lib/tools.jar $CATALINA_HOME/common/lib
    Restart tomcat.
    Deploy your webapp as usual which will include your JSP files stored under your webapp's 'web' directory. No precompilation of JSPs is required. Then access your JSP pages such as http://localhost:8080/HelloWorld/my-jsp-page.jsp and tomcat will compile it on the fly on first access. The disadvantage is that there will be a slight delay on first access.
    [Note:  I am putting all this down for the record, because it took me MANY HOURS to figure all this out as the info on how to do this is not found clearly in one place!!  Hope this helps others.]
    My next step is to incorporate the contents of compile.xml as mentioned above, into my regular build.xml file.

  • Problem Accessing Class in my package from jsp file

    Hi,
    I am using Apache tomcat server and i have made package which contains a class for database connection. I have imported this package in my jsp file but when i run the jsp tomcat gives the class not found exception. i have placed the jsp file in /webapps/my_project/ folder and the package in the /webapps/my_project/WEB-INF/classes/ folder.
    Still its not working.
    Please help me out!!!!!!!!

    hi,
    Thanks for ur reply. You have guessed it right, i dont have a .jar file its a .class file in a package subfolder. I have tried out ur suggestion but it didnt work. The following error i shown when i run it.
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    C:\Apache Tomcat 4.0\work\localhost\_\College\test$jsp.java:4: Package college_lib not found in import.
    import college_lib.*;
    ^
    1 error, 1 warning
    Here, College_lib is the package name which contains the class my class file
    Is there any problem with my Apache Tomcat4.0 or any other thing.
    Message was edited by:
    Despo

  • Problems with Tomcat 4.0 and jdk 1.3.1 (jsp:include) Help Gurus...

    Im running examples of the include:
    <jsp:include page="xxx.jsp" flush="true">
    and received error:
    org.apache.jasper.JasperException: No se puede compilar la clase para JSP
    An error occurred at line: 17 in the jsp file: /jsp/include/include.jsp
    Generated servlet error:
    /Programas/Tomcat4/work/localhost/examples/jsp/include/include$jsp.java:79: Method include(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, javax.servlet.jsp.JspWriter, boolean) not found in class org.apache.jasper.runtime.JspRuntimeLibrary.
    JspRuntimeLibrary.include(request, response, "/jsp/include/foo.html" + jspxqStr, out, true);
    ^
    Please Help me Im running this equal with:
    <%@ include file="xxx.jsp" %>
    and runnig fine....

    The two means of including files are different in their approach.
    Using <jsp:include .../> compilation of the included jsp is done at run -time not during compilation.
    Using <%@ include .../> compiles at compile time.
    Looking at the error it seems that the method JspRuntimeLibrary.include is not being found which suggests that you may have a classpath problem. Check that there is not a servlet.jar in the classpath that is from a earlier spec than the one provided with Tomcat.
    Dave

  • Problems running jsp files with tags on tomcat 4.0

    hi,
    i had some jsp1.1 stuff running on tomcat3.3.
    last week i moved to tomcat 4.0 , changed the tags to fit jsp1.2 and... everything is wrong now. while trying to run jsp with tags i get an error message (same for all files):
    ---->
    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: (class: org/apache/jsp/djsp$jsp, method: _jspService signature: (Ljavax/servlet/http/HttpServletRequest;Ljavax/servlet/http/HttpServletResponse; )V) Incompatible object argument for function call
    <-------
    the jsp files with no tags and servlets are running ok.
    I NEED YOUR HELP!!!

    cyclid,
    i have the same environment setup and the same troubles. after searching the forums, it seems that there are others with the same, if not similar issues, yet no solutions. if you find the solution to this one, could you please post it. i would really appreciate it since i have been on this one for several days with no success. i even tried the helloworld jsp/custom tag examples from a jsp profession book that i have and that won't work.
    Anyone out there,
    if you have any idea why this problem exists, any solutions, ideas would be appreciated.
    thank you,
    navesink

  • Problem in configuring my Laptop to run JSP files

    I am having problem in testing my finished JSP files in my laptop. Everytime I run my JSP, it continues requesting for internet connections. It cannot run in an offline modus. I am using Mindows 2000, JDeveloper 3.2.3 and Oracle 9i database.I installed IIS(Internet Information Server). I need urgent help because of my school presentation.

    Hi,
    Please check this link and follow the guide to configure exchange online account to your IPhone:
    https://support.office.com/en-SG/Article/Set-up-email-on-Apple-iPhone-iPad-and-iPod-Touch-b2de2161-cc1d-49ef-9ef9-81acd1c8e234
    Since this forum is for general questions and feedback related to Office for windows, if you need further assistance on this issue, you can post in the following forum:
    https://social.technet.microsoft.com/Forums/msonline/en-US/home?forum=onlineservicesexchange
    The reason why we recommend posting appropriately is you will get the most
    qualified pool
    of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Use javabean object from jsp file

    I try to use JDBC to open database, find my record and initiate and return a static object of javabean class. In my jsp file, I try to use this object, but it is null. My directory is C:/tomcat/webapps/myapp/web-inf/classes/bean. A "jsp" folder is under "myapp" directory. I put jsp file in "jsp" and bean class in "bean".
    Is there some one can give me some suggestions?
    thank you!
    Qiang

    I assume that the constructor for your object is inside the static method.
    If the static method returns null, then the object is not being constructed.
    There is nothing wrong with the JSP.
    Thus the best place to look will be inside the static method. Use tracers like System.out.println() and printStackTrace() and I am sure u will find the problem.
    One thing was not very clear to me. If u construct your object within the static method, there must be some reason for that. Since you are using parameters, this does not look like a singleton. Rather I think it is one object per input combinations you have provided. It is interesting as I have never seen this kind of code before(Except session EJB) It will be a nice learning experience if you post some documents regarding your design.
    Shubhrajit

  • Need help in using SQL in a jsp file to compare date and time

    hi every one,
    Actually I am doing a project using JSP. I need to compare a date field in the database (MS Acess) to the current system date and time. I have to do this in a select statement.
    I have alredy defined a variable of type Date in the JSP file and I am comparing this variable to the date in the database through a select statemant.
    Here is what I am doing
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
              java.util.Date today = new java.util.Date();
              String myDate=sdf.format(today);
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= "+myDate+" ;";
    EDate is the feild in the database and it's format is (5/12/2008 5:29:47 PM) it is of type Date/Time in MS Acess.
    when I execute the query it gives the following error
    SQL error:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'EDate <= 2008-10-16 08:10:07'.
    I hope any one can help me with that error and answer my question, I've tried too many things but nothing helps
    Thanks in advance :-)

    Hi,
    When the comparision is needed to be done with the current date , we don't need to send in Java
    Date then format it and compare with MS Acess Date.
    In MS Access we have Date() function which will give you the current date.
    So you can try rewriting your query as following :
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= Date() ;"; ---------------------
    Hope this helps.
    Thanks

  • My IPod no longer shuffles songs within playlists that are clearly set to shuffle.  It is about 3/4 full so I thought of maybe compressing the files to get more space.  Do you think that is the problem and if that might help?

    My IPod no longer shuffles songs within playlists that are clearly set to shuffle.  It is about 3/4 full so I thought of maybe compressing the files to get more space.  Do you think that is the problem and if that might help?

    Storage space on the iPod would not affect shuffled playlists or playlist shuffling, though substantially full iPods may wind up skipping songs on larger playlists after a while, and require a restart.  As for compressing the files themselves, you can automatically re-encode files to a lower bitrate by checking the box on the summary page when your iPod is connected to your PC/Mac.
    As for the shuffle problem, after restarting your iPod (hold the center button and Menu for a few seconds, until the Apple logo appears), make sure you're telling the iPod to shuffle the songs in a playlist by repeatedly clicking the center button until the Suffle Menu comes up, then scroll to the right to turn it on.  From that song forward, the playlists' contents should be shuffled every time the playlist ends, or is accessed from a new song.
    Shuffle does sometimes turn itself off, I've found, so double-check the setting is still on.  Also, iPods shuffle by randomly assigning a playlist order for your songs, which is different from traditional shuffle (on, say, iTunes or Windows Media Player, where the new song is determined at random upon the current track ending.  The iPod only chooses a random order of songs when you shuffle, to conserve battery life and queue up songs coming up on the playlist in the event of a shock).

Maybe you are looking for