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

Similar Messages

  • Help with jsp and javaBean in eclipse/Tomcat

    Hi,
    I am new to JSP and JavaBean. I am going through tutorial for a jsp page that uses a javaBean. I am using eclipse to create jsp page and the java bean.
    My eclipse project "Date" has five package as under:-
    1. Deployment Descriptor
    2. Java Resources: src
    3. build
    4. WebContent
    I have my data.jsp page in WebContent/WEB-INF/ folder. When I just run date.jsp in a browser as: http://localhost:8080/Date/date.jsp, it gets launched into the browser correctly. But when I add a JavaBean "TimeFormatterBean.java" in the Java Resources:src folder and use it in date.jsp page, I get errors as under:-
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 5 in the jsp file: /date.jsp
    TimeFormatterBean cannot be resolved to a type
    2: pageEncoding="ISO-8859-1"%>
    3: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    4:
    5: <jsp:useBean id="formatter" class="TimeFormatterBean"/>
    6:
    7: <html>
    8: <head>
    The data.jsp page is as under:-
    <jsp:useBean id="formatter" class="TimeFormatterBean"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
         <h1> Date JSP </h1>
         <p> The  current time is:
         <%= new java.util.Date() %>
         <jsp:getProperty name="formatter" property="name"/>
         </p>
    </body>
    </html>I can see "TimeFormatterBean.class" in build/classes folder.
    If anyone could please help me out with this, it would be very helpful
    Thanks a lot!

    You probably should place TimeFormatterBean inside a package, or maybe you could try importing it , even if it�s in the default package, with something like this <%@ page import="TimeFormatterBean" %> at the top

  • Any CASE tools for Java, JSP, and JavaBeans?

    For Java, JSP, and JavaBeans can we find something that can help us automate certain tasks?
    For example, CASE tools is an acronym for Computer Aided Software Engineering tools. I have a colleague use software to generate robust code for the database layer and with a few clicks of a button after the database is designed he can generate code that would otherwise take an hour or even hours to write and debug and test.
    Thanks for your time and help in advance!
    Cecilia

    The ones I know are MVCase (from Brazil) and Jude (from Japan). Both are free and I haven't fully tested them yet. It may help you.

  • Jsp and JPanel problem

    Hello. I've been to this forum many times, but have always been a bit gunshy about posting anything of my own. Now I have a problem I haven't seen before, so here goes. I have a JPanel in a java program that has all sorts of other componants added to it. I am trying to display the whole thing in a jsp page. This is what I am doing in the java file to return the image ("display" is the JPanel):
    public byte[] getImage(){
        int w = display.getWidth();
        int h = display.getHeight();
        BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        display.paint(img.createGraphics());
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        ImageIO.write(img, "jpeg", os);
        return os.toByteArray();
    }and then in the jsp page I say:
    <%@ page contentType="image/jpeg" %>
    <%@ page import="myPackage.MyClass" %>
    <%
         MyClass picture = new MyClass();
         byte[] b = picture.getImage();
         OutputStream os;
         os = response.getOutputStream();
         os.write(b);
         os.flush();
    %>And the problem is that the page is displaying a blank JPanel and none of the componants that were added to it. If I save the the JPanel as a jpeg in the java program, though, it does contain all the componants, so I am not sure what I am doing wrong here. If there is some way to get the all the JPanel componants returned, that would be great to know. Thanks for any help.

    nope, that didn't work.
    Maybe I am going about solving the problem all wrong. The JPanel and its componants are kind of like a template. When a user of the system submits their information it automatically puts the data into the template and displays it on screen as a jpg. It works when I save the jpg as a file from the java program but not when i send the byte array to the jsp server. It just shows the blank panel....
    Is there a better way to go about doing this?

  • JSP and Tomcat Problem

    Folks,
    My apologies if this is off-topic for this forum, but I've been having this problem using Tomcat and JSP. I'm fairly new to Java.
    Basically, I'm writing a webapp that uses servlets and JSP together. The servlet and backend classes all compile fine. Now, basic frontend page is called Console.jsp, and one of the commands that it runs is <%@ page import="DJUser">
    Here's the problem: Console.jsp is in $CATALINA_HOME/webapp/
    DJUser (and the rest of the classes I'm using) are in $CATALINA_HOME/webapp/WEB-INF/classes
    When I attempt to run Console.jsp I get this error:
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    The import DJUser cannot be resolved
    An error occurred at line: 9 in the jsp file: /Console.jsp
    Generated servlet error:
    DJUser cannot be resolved to a type
    An error occurred at line: 11 in the jsp file: /Console.jsp
    Generated servlet error:
    user cannot be resolved
    An error occurred at line: 11 in the jsp file: /Console.jsp
    Generated servlet error:
    DJUser cannot be resolved to a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    The ROOT CAUSE is listed as:
    java.lang.ClassNotFoundException: org.apache.jsp.Console_jsp
         java.net.URLClassLoader$1.run(URLClassLoader.java:200)
         java.security.AccessController.doPrivileged(Native Method)
         java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133)
         org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
         org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596)
         org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    I'm running Tomcat 5.5.12 on Mac OS X 10.4. Could this be a permissions issue somehow? For right now (testing purposes only) I have tomcat running under my (non root) account.
    I've been scouring the web for a while, and I can't really find anything on this. I'd appreciate any help you could give me.
    Thanks!
    Dylan

    Put the DJUser java file in a package (say com.myClasses) and recompile. Then put the DJUser class file under the WEB-INF/classes directory in the proper package structure (WEB-INF/classes/com/myClasses/DJUser). Stop and restart the server to pick up the new classes. Make sure to change the jsp import statement ( <%@ page import="com.myClasses.DJUser">)

  • Jsp and javascript problem

    I have a JSP page with a table of n rows. Each row has the option of having
              a dropdown list appear on that particular row. The user should have the
              ability to make a selection from the drop down list and have the page change
              to the correct page automatically or it can allow the user to change and
              have them click on a link that passes the value of the select box as a
              parameter to the proper page.
              The problem is that each row CAN NOT be in it's own form. The action for
              the current form is NOT the action I want the select box to use.
              I can't seem to figure out how to get the value of the select box in
              javascript passed as a parameter using a JSP variable.
              Example code:
              <form method="post" action="/index.jsp">
              <table>
              <tr>
              <td> Remove Row? </td>
              <td> View Options? </td>
              <td> Name </td>
              </tr>
              <tr>
              <td> <input type=checkbox name='<%=rowNumber %>' value='<%=
              someCheckboxValue %>'> </td>
              <td> <select name=selectOptions>
              <option value="option 1">option1</option>
              <option value="option 2">option2</option>
              <option value="option 3">option 3</option>
              </select>
                View Option  
              </td>
              <td> <%= rowName %> </td>
              </tr>
              <tr>
              <td colspan="3"> <input type=button name='UpdateExampleForm'
              value='Submit'> </td>
              </tr>
              </table>
              </form>
              

    actually i am taking menus from database in file ourmenu.jsp
    and i have another file called menu.js which displays the menus on browser
    menu.js is the file which i have downloaded from net
    and i want to use at it is but with a difference that it should display the menus which r coming from database
    in file ourmenu.jsp i have saved the menus in array so can anyone tell me how to refer them in my .js file.
    i have tried with foll. code::
    var aUsername =new array();
    <% i=0;
    while (padtemp[i] != null)
    %>
    aUsername[<%= ++i%>] = "<%= padtemp[i] %>";
    in .js file but i am getting no o/p on browser
    i have tried with runat=server while including the .js file in .jsp file but its not working too.
    can anyone help please
    thanks in advance

  • JSP AND BEAN PROBLEm   java.lang.nullpointerexception   help me please

    hello i have a problem, when i open login.jsp and enter the form i have nullpointerexception. i don't understand where i wrong... i use tomcat 5.5 ... sorry for my english i'm italian and i speak only italian :(
    login.jsp this is the code of the java server page
    <html>
    <%@ page language="java" import="java.sql.*" %>
    <jsp:useBean id="lavoro" scope="page" class="Ok.Dino"/>
    <%@ page session="false" %>
    <style type="text/css">
    <!--
    body {
         background-color: #003366;
    a:link {
         color: #CCCCCC;
    .style1 {
         color: #000000;
         font-weight: bold;
         font-size: x-large;
    .style4 {font-size: 18px}
    -->
    </style>
    <body>
    <%if(request.getMethod()=="GET"){
    %>
    <form action="login.jsp" method= "POST" name="frmlogin" id="frmlogin">
         <div align="center">
           <p class="style1">AUTENTICAZIONE</p>
           <p> </p>
           <table width="318" height="140" border="1">
            <tr>
              <td width="95" height="60" bordercolor="#000000" bgcolor="#0066CC"><p align="center"><strong>USER</strong></p>          </td>
              <td width="207" bgcolor="#0099CC"><p align="center">
                <input type="text" name="txtnome"></p>
              </td>
            </tr>
            <tr>
              <td height="72" bordercolor="#000000" bgcolor="#0066CC"><strong>PASSWORD</strong> </td>
              <td width="207" bgcolor="#0099CC"><div align="center">
                <input name="pwdtxt" type="password">
              </div></td>
            </tr>
          </table>
           <table width="318" border="1">
            <tr>
              <td width="318" height="87"> <div align="center">
                <input name="submit" type="submit" value="invia"  >
              </div>
              <p align="center"><strong><span class="style4">Se non sei registrato fallo <a href="file:///C|/Documents and Settings/access/Documenti/My Received Files/registrazione.jsp">adesso </a></span></strong></p></td>
            </tr>
          </table>
           <p> </p>
           <p> </p>
      </div>
    </form>
    <%}else {  %>
    <%lavoro.settxtnome(request.getParameter("txtnome"));%>
    <%!ResultSet rs=null;
         String x=null;
    %>
    <% lavoro.cn_db("dbutenti");%>
    <% rs=lavoro.run_query("SELECT user FROM utenti");%>
    <%}%>
    </body>
    </html>and this is the bean code
    package Ok;
    import java.sql.*;
    public class Dino
    private String txtnome,pwdtxt;
    private Connection cn=null;
    private Statement st=null;
    private ResultSet Rs=null;
    public String gettxtnome()
    return txtnome;
    public String getpwdtxt()
    return pwdtxt;
    public void settxtnome(String n)
    this.txtnome=n;
    public void setpwdtxt(String n)
    this.pwdtxt=n;
    public void cn_db(String db)
              if(cn==null){
              //1. Caricamento del driver
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              }catch(ClassNotFoundException cnfe){
                   System.out.println("impossibile caricare il driver");
                   System.exit(1);
              try{
                   //2. Connessione al DB
                   cn = DriverManager.getConnection("jdbc:odbc:"+db);
                   //3. creazione degli oggetti Statement e ResultSet
                   st =cn.createStatement();
              }catch(SQLException e){
                   System.out.println(e+"jjj");
    }else{
         System.out.print("errore database gi�� creato");
    public ResultSet run_query(String qr)
         try{
    Rs=st.executeQuery(qr);
         }catch(SQLException e)
         System.out.print(e+"ecco l'error");
         return Rs;
    }

    Do you understand when a NullPointerException will be thrown? This will be thrown if you want to access an uninstantiated Object.
    So look to the stacktrace and go to the line where the NPE is been thrown and doublecheck if the object reference is actually instantiated.
    Or add a null-check to the object reference:if (someObject != null) {
        someObject.doSomething();
    }or just instantiate it:if (someObject == null) {
        someObject = new SomeObject();
    someObject.doSomething();

  • JSP and JavaBeans...

    Hi,
    I have a JavaBean(class file) and iam able to use it,when i kept the
    filename.class in the "root_dir/webapps/ROOT/WEB-INF/classes" directory and
    myJsp.jsp file in "root_dir/webapps/ROOT" directory.
    But not,when it is in the follwoing Directories
    .class file in "root_dir/webapps/ROOT/WEB-INF/classes" (No change)
    .JSP file in "root_dir/webapps/ROOT/myDir" (/myDir/myJsp.jsp)
    In my JSP file iam calling Bean as follows
    <jsp:useBean id="mybean" scope="session" class="bean.class" />
    (not giving .class extension)
    and executing the program like this "http://localhost:8080/myDir/myJsp.jsp"
    Iam using Apache Tomcat 3.3a webserver,
    what is the path that i have to give in the class attribute of <jsp:useBean>?
    Thanks in Advance..
    Regards
    Rao

    I got it...
    Rao.

  • Jsp and db2 problem

    Hi guys:
    I installed tomcat4, db2 run time client on one red hat 7.2. Everything works fine. My jsp can access db2 database.
    Now I am installing the same thing into another box, red hat 7.2, tomcat4 and db2 run time client.
    I can write a java code to access the db2 database, and I can access db2 table in the command line. Jsp file is running fine. But when I use the jsp code which is working in another red hat box to access the db2 database, it can not go through and it stops in "Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");" statement.
    Does any body have any idea what could be the problem?
    Regards,
    David

    hi,
    could you please send me the jsp-db2 connection code.i am really distressed.i can't find it anywhere..must i install db2 run client. i have only db2 personal edition and the rest( tomcat,jre,jsdk,etc..)
    Thx
    (while tipping my e-mail in registration,i wrote it false)
    My treu e-mail is [email protected]
    please please send me this code....

  • JSP and JavaBean simple question, pls help

    Hello,
    I am new to JSP. I just installed Sun Java Studio Enterprise 8 to create a JSP project. I created a jsp file and java class file in the same project. the class file is in default package. I use <jsp:useBean id="date" class="DateFormatBean"/> in jsp file to call the java class. When I run the jsp page I got the error:
    cannot resolve symbol
    symbol : class DateFormateBean
    if I add a package in the class file, I got the error: package com.mycom.projsp does not exist.
    Also I tried to add a jar file into the library and tried to import it in my jsp page, I also got package doesn't exist error.
    I know I need to set the classpath and I did it, but still got the error. Could someone help me out? Do I miss some settings? I am using Tomcat.
    Thanks in advance!

    i'm not familiar with Java Studio Enterprise 8 so i'm not sure how it is organizing its project. However, i know tomcat...and if for test purposes you take your jsp file and put it in $TOMCAT_HOME/webapps/ROOT and your class file and put it in $TOMCAT_HOME/webapps/ROOT/WEB-INF/classes, things should work out. perhaps the web app isn't being organized properly in your tool.
    hope that helps.

  • JSP and JavaBean - Session info and constructors

    Hello,
    I'm trying to write a simple web page that allows used to login and view thier detail from a DB.
    I can't figure few things :
    1) why the dalpkg.SayHello class is loaded every time the page is loaded? and how can I change it?
    2) In the login page I prompt a login form, what I want to do is :
    If a user is already logged on and re-enters this page, the form wont be shown to him, instead he will see some other information.
    how can it be done?
    I tried to save a global parameter in the class ("Validated") but it seems that every time i re-enter the login page this variable is false.
    login jsp page :
    <br />
    <jsp:useBean class="dalpkg.SayHello" id="info" scope="page">  <br />
    <html>  <br />
    <head>  <br />
    <title>LOGIN</title>  <br />
    </head>  <br />
    <br />
    <body>  <br />
    Users in the system :  <%=info.CountRows()%>   <br><br />
    <br />
    <form name="example" method="get" action="hello.jsp">  <br />
    <br><br />
    <center> username : <input type="text" name="username"><br />
    <br><br>  <br />
    password : <input type="password" name="password"> <br />
    <br><br><br />
    <input type="submit" name="sub" value="submit"> </center><br />
    </form>     <br />
    <%=info.Validated%><br />
    </body>  <br />
    </html><br />
    </jsp:useBean>hello jsp page (shows user info) :
    <br />
    <jsp:useBean id="settings" scope="application" class="dalpkg.SayHello"/><br />
    <jsp:setProperty name="settings" property="*"/><br />
    <html><br />
    <head><br />
    <title>Setting UP</title><br />
    </head><br />
    <body><br />
    <center><br />
    <h1> Hello!! </h1><br />
    <br />
    <%settings.Validate(response);%><br />
    <br><br />
    Fullname : <%=settings.getFullname()%><br />
    <br><br />
    Gender : <%=settings.getGender()%><br />
    <br><br />
    Hobby : <%=settings.getHobby()%><br />
    <br />
    <br><br />
    <a href="start.jsp">START</a><br />
    <br />
    </center><br />
    <br />
    </body><br />
    </html>

    and the java bean code :
    package dalpkg;
    import java.util.*;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class SayHello
        String Username ="";
        String Password ="";
        String Fullname;
        String Hobby;
        String Gender;
        public boolean Validated = false;
        public void SayHello()
         public void setUsername(String username)
            this.Username = username;
         public void setFullname(String fullname)
            this.Fullname = fullname;
         public void setHobby(String hobby)
            this.Hobby = hobby;
          public void setGender(String gender)
            this.Gender = gender;
         public void setPassword(String password)
            this.Password = password;
        public String ReturnHello()
            return System.getProperty("user.dir");
        public String getUsername()
            return this.Username;
        public String getPassword()
            return this.Password;
          public String  getFullname()
            return  this.Fullname;
         public String getHobby()
            return this.Hobby;
          public String getGender()
            return this.Gender;
       public String  Validate(HttpServletResponse response) throws IOException
              String  ReturnValue = "NOT OK";
              if(ValidateUser(getUsername(),getPassword()) != "OK")
                    response.sendRedirect("start.jsp");
              else
                    try
                         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                         Connection con=
                                        DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\DB1.mdb;}");
                                    Statement stmt=con.createStatement();
                          ResultSet rs=stmt.executeQuery("select fullname,hobby,gender from users where username = '"
                                  + getUsername() +"'");
                        while(rs.next())
                                    setFullname(rs.getString(1));
                                    setHobby(rs.getString(2));
                                    setGender(rs.getString(3));
                         this.Validated = true;
                         ReturnValue = Boolean.toString(Validated);
                    catch(Exception e)
                         StringWriter sw = new StringWriter();
                        e.printStackTrace(new PrintWriter(sw));
                        String stacktrace = sw.toString();
                        ReturnValue = stacktrace;
              return ReturnValue;
        public String CountRows()
            String ReturnStr;
            int Counter =0;
            try
                       Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        Connection con=
                                DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\DB1.mdb;}");
                            Statement stmt=con.createStatement();
                        ResultSet rs=stmt.executeQuery("select *from users");
                        while(rs.next())
                            Counter ++;
                        ReturnStr = Integer.toString(Counter);
            catch( Exception e)
                StringWriter sw = new StringWriter();
                e.printStackTrace(new PrintWriter(sw));
                String stacktrace = sw.toString();
                ReturnStr = stacktrace;
            return ReturnStr;

  • Express and javabean problems

    ///////////////////////////////index.jsp
    <body>
    <% java.util.Vector vector = new java.util.Vector();
         vector.addElement("one"); vector.addElement("two");
         vector.addElement("three"); vector.addElement("four");
    %>
    Iterating over <%= vector %> ...<p>
    <it:iterate collection='<%= vector %>'>
    <jsp:useBean id='item1' scope='page' class='java.lang.String'/>
    Item: <%=item1%> <br>
    </it:iterate>
    //////////////////////output
    Iterating over [one, two, three, four] ...
    Item: one
    Item: two
    Item: three
    Item: four
    1) about the expression <%= vector %>.
    Why all the objects in the collection can be output automatically?
    2)Usually jsp:useBean is used on an instance of the self-defined class. But in this example it's a String object. Within the custom tag file, it has something like
    iterator = collection.iterator();
    pageContext.setAttribute("item1", iterator.next());
    Then in index.jsp, <%=item1%> can output the objects in collection?
    Why?

    1) about the expression <%= vector %>.
    Why all the objects in the collection can be output automatically?Thats the standard implementation of the vector.toString() method.
    It just goes through all the objects in the vector, and calls toString on each of them. Sometimes that is useful, sometimes not.
    2) is a bit more complicated
    Basically the useBean tag sets up a variable that you can use in jsp scriptlets called item1. It gets its value from the page attribute "item1"
    The attribute got set from the iterator code as you showed.
    The reason <%= item1 %> can output the objects is because the useBean tag declared it as a local variable and retrieved its value.
    The useBean tag would translate into code something like:
    // jsp code
    <jsp:useBean id='item1' scope='page' class='java.lang.String'/>
    Item: <%=item1%> <br>
    // equivalent java code
    String item1 = pageContext.getAttribute("item1");
    out.print("item:");
    out.print(item1);
    out.print("<br>");Thats all the whys and wherefores.
    I presume you are looking at someone elses code?
    But there is a btter way of iterating now. The JSTL forEach tag is just like this one only better.
    <c:forEach var="item1" items="${vector}">
      Item: <c:out value="${item1}"/>
    </c:forEach>cheers,
    evnafets

  • JSP and package deployment problem in Tomcat 5

    Hi,
    I tried very simple exercise that includes JSP and javabean (from package), but I have the following error:
    HTTP Status 500 -
    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: -1 in the jsp file: null
    Generated servlet error:
    [javac] Compiling 1 source file
    [javac] C:\jwsdp\work\Catalina\localhost\exercises\org\apache\jsp\ex01\ex01_jsp.java:10:
    package pack01 does not exist
    [javac] import pack01.ex01;
    [javac] ^
    Bellow are all my sources
    1. directory structure
    ========================
    C:\jwsdp\webapps\exercises
    index.html
    C:\jwsdp\webapps\exercises\ex01
    build.bat
    ex01.jsp
    C:\jwsdp\webapps\exercises\ex01\WEB-INF
    web.xml
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\classes
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\classes\pack01
    ex01.class
    ex01.java
    C:\jwsdp\webapps\exercises\ex01\WEB-INF\lib
    pack01.jar
    2. sources
    ==========
    << ex01.jsp >>
    <HTML> <HEAD> <TITLE>Ex01</TITLE> </HEAD>
    <BODY>
    <FORM METHOD="GET" ACTION="ex01.jsp">
    <%@ page import = "pack01.ex01" %>
    <H2>Ex01</H2>
    <jsp:useBean id = "x" class = "ex01" scope="application"/>
    </FORM>
    </BODY> </HTML>
    << ex01.java >>
    package pack01;
    import java.io.*;
    public class ex01 implements Serializable {
    private String value;
    public ex01() {
    value = "EX01";
    public void setValue(String s) {
    value = s;
    public String getValue() {
    return value;
    << build.bat >>
    cd WEB-INF\classes\
    cd
    del ex01.jar
    javac -deprecation -verbose pack01\ex01.java
    jar cvf ..\lib\pack01.jar pack01\ex01.class
    << C:\jwsdp\webapps\exercises.xml >>
    <Context className="org.apache.catalina.core.StandardContext"
         cachingAllowed="true"
         charsetMapperClass="org.apache.catalina.util.CharsetMapper"
         configFile="webapps\exercises.xml"
         cookies="true"
         crossContext="false"
         debug="0"
         displayName="Exercises"
         docBase="C:\jwsdp\webapps\exercises"
         domain="Catalina"
         engineName="Catalina"
         j2EEApplication="none"
         j2EEServer="none"
         lazy="true"
         mapperClass="org.apache.catalina.core.StandardContextMapper"
         path="/exercises"
         privileged="false"
         reloadable="true"
         startupTime="30"
         swallowOutput="true"
         useNaming="true"
         wrapperClass="org.apache.catalina.core.StandardWrapper" >
    </Context>
    What is wrong ?
    I have Windows NT and Tomcat 5 (from jwsdp 1.2).
    Thank you,
    Alex.

    I just tried to reproduce the problem with old version of Tomcat (4.0.2) and ... it works. It is definitely specific for Tomcat 5 (or may be one of the late Tomcat 4 as well). There is another related difference:
    With Tomcat 4 I could create javabean in class subdirectory (default package) and use
    <%@ page import="ex01" %>
    Now with Tomcat 5 I have syntax error in this line.
    This syntax error disappeared when I moved javabean into package pack01.

  • Two JSPs using JavaBeans

    Hi,
    I have a JSPs and JavaBeans question.
    There are two JSP files. One.jsp and Two.jsp.
    One.jsp include code that use the JavaBeans from Two.jsp:
    <%
         if (bl.getDmlOperation() == NcepConstants.UPDATE) {
    Two.jsp have:
    <jsp:useBean      id="bl"     class="TestsPrivateBean" scope="session"/>
    <%@ include file="One.jsp" %>
    When I run this code in TOMCAT, it can run in runtime with no problem.
    But the company it now moving to use an IDE (Oracle JDeveloper 9i) with require me to build this into one project. When I try to build the project, it shows error in One.jsp as "variable bl not found in class_One".
    When I put the <jsp:useBean      id="bl"     class="TestsPrivateBean" scope="session"/> code into Two.jsp, it shows "duplicate found error".
    How should I do to fix this?
    Thanks
    Kenny

    It sounds like it's compiling One.jsp independant of Two.jsp, which will cause the first error. Try renaming One.jsp to One.inc or something. That way it doesn't try compiling One.jsp at all (it won't be there).

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

Maybe you are looking for

  • Low Memory when Printing Excel chart on LaserJet 3015 ll-in-one

    Low Memory when Printing Excel chart on LaserJet 3015 ll-in-one When I try to print a chart from Excel 2007 I get a low memory error. All other printing seems to work just fine. I thought it might be because of a color fill in the chart area so I rem

  • Can somebody please help me with this Panic Report?

    Hi Guys, I am having a little difficulty deciphering these panic reports we keep getting from our Mac Pro here. They've been crashing our Mac ever since we got our Hasselblad Camera back from Hasselblad repair however after submitting logs to Hasselb

  • If you recycle a ipod do you just have to get a iPod

    Can you recycle an iPod and buy anything other than an iPod

  • Price agreement in sales order

    Hi, Can anyone guide me how to use the pricing agreement hearer and item in sales order. Both these fields are greyed out. The path is extras - price agreements - header/item Thanks

  • Unable to transfer

    When I try to transfer music from another user library to mine it won't let me it keeps saying there is a network timeout. However it lets that user take from my library. I never had this problem until i've gotten a new laptop. Please help