If your bean is in the package email
and compile into c:\orion\default-site\beans\ 
you should have in your classpath:

c:\orion\default-site\beans\
not
c:\orion\default-site\beans\email;

Luciano



-----Messaggio originale-----
Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Inviato: mercoledì 26 gennaio 2000 17.54
A: Orion-Interest
Cc: [EMAIL PROTECTED]
Oggetto: Model View Controller (MVC) Appliction Will Not Compile


Hi,

I wrote a very simple web application (codes below) using the MVC design
pattern and trying to test it on orion 0.8.2  

The View
--------
email.jsp (stored in the directory I created --
c:\orion\default-site\html\examples\jsp\email\ )
The Controller
--------------
EmailServlet.java (in directory c:\orion\servlets\ )

The Model
---------
EmailBean.java (in directory I created -- c:\orion\default-site\beans\email\
)


I set the classpath like this: set
CLASSPATH=.;c:\orion\default-site\beans\email;c:\orion\servlets;c:\orion\ser
vlet.jar

I imported the email.EmailBean into the EmailServlet.java (see code below)
But when I compiled the EmailBean.java (code below) it works, but when I try
tocompile the Emaiservlet.java it gives the following error: 'Can't read:
EmailBean.java
1 error'.  
How do I set up the servlet and bean so that the servlet fines the bean in
its pacakage.

File: email.jsp
--------------
<html>
<head>
<title>Register Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">

<jsp:useBean id="email" scope="request" class="email.EmailBean" />
<jsp:setProperty name="email" property="*" />

<p>&nbsp;</p>
<p>If you want to be notified please enter your e-mail below</p>
<form method="post" action="">
<table width="75%" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <td width="16%">e-mail:</td>
    <td width="84%">
        <input type="text" name="textfield" size="50" maxlength="50">
      </td>
  </tr>
</table>
</form>
</body>
</html>

File: EmailServlet.java
-----------------------

import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import email.EmailBean;


public class EmailServlet extends HttpServlet{

    private Connection con = null;
    private PreparedStatement ps = null;
    private String email = null;
    private String userName = "";
    private String password = "";
    private String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
    private String connectionURL = "jdbc:odbc:emailsource";
    private EmailBean mail = new EmailBean();


    public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException{



      try {
          Driver d = (Driver)Class.forName(driverName).newInstance();
      } catch (Exception e) {
        System.out.println(e);
      }


      try{
        con = DriverManager.getConnection(connectionURL,userName,password);
      }catch(Exception e){
        System.out.println(e);
        }

     email = mail.getEmail();
     System.out.println("debug:  Got here " +  email);

     try{

      ps = con.prepareStatement("INSERT into EmailContacts " +
                        "(Email) " +
                        "values(?)");

      // set the statement values

      ps.setString(1, email);


       // execute the statement
      ps.executeUpdate();

      // rc = true;
      con.commit();
      con.close();
      System.out.println("Debug -- Got Here" + " " + email);


    }
    catch(SQLException e){
      System.out.println(e);
    }
    catch(NullPointerException ex){
     System.out.println(ex);
    }

    try {
            // Set the attribute and Forward to hello.jsp
         request.setAttribute ("servletName", "servletToJsp");
 
getServletConfig().getServletContext().getRequestDispatcher("/examples/jsp/v
ote/thankyou.jsp").forward(request, response);
    } catch (Exception ex) {
          ex.printStackTrace ();
      }

  }
}


File:  EmailBean.java
----------------------
package email;

public class EmailBean {

        private String email = null;

        EmailBean(){
        }

        public void setEmail(String email){
                this.email = email;
        }

        public String getEmail(){
                return email;
        }

}

Reply via email to