• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

javabean problem

 
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my Customer.class

package estore;

import java.sql.*;
import java.io.*;
import java.util.*;


public class Customer
{
private String FName;
private String LName;
private String Address;
private String City;
private String Country;
private String Zipcode;
private String Telephone;
private String EMail;

private int Customer_ID;

public Customer(int Customer_ID,String FName,String LName,String Address,String City,
String Country,String Zipcode,String Telephone,String EMail)
{
this.Customer_ID = Customer_ID;
this.FName = FName;
this.LName = LName;
this.Address = Address;
this.City = City;
this.Country = Country;
this.Zipcode = Zipcode;
this.Telephone = Telephone;
this.EMail = EMail;
}

public int getCustomer_ID()
{
return Customer_ID;
}

public void setCustomer_ID(int id)
{
Customer_ID = id;
}

public String getFName()
{
return FName;
}

public void setFName(String fn)
{
FName = fn;
}

public String getLName()
{
return LName;
}

public void setLName(String ln)
{
LName = ln;
}

public String getAddress()
{
return Address;
}

public void setAddress(String addr)
{
Address = addr;
}

public String getCity()
{
return City;
}

public void setCity(String cit)
{
City = cit;
}

public String getCountry()
{
return Country;
}

public void setCountry(String countr)
{
Country = countr;
}

public String getZipcode()
{
return Zipcode;
}

public void setZipcode(String zc)
{
Zipcode = zc;
}

public String getTelephone()
{
return Telephone;
}

public void setTelephone(String tele)
{
Telephone = tele;
}

public String getEMail()
{
return EMail;
}

public void setEMail(String em)
{
EMail = em;
}

private boolean ValidateFields()
{
//String FName = Customer.getFName();
//String LName = Customer.getLName();
//String Address = Customer.getAddress();
//String City = Customer.getCity();
//String Country = Customer.getCountry();
//String Zipcode = Customer.getZipcode();
//String Telephone = Customer.getTelephone();
//String Email = Customer.getEMail();

if ((FName.equals("")) | (LName.equals("")) | (Address.equals("")) | (Country.equals("")) |
(Telephone.equals("")) | (EMail.equals("")) | (City.equals("")) | (Zipcode.equals("")))

return false;
else
return true;

}

private void CreateCustomer() throws ClassNotFoundException,SQLException,IOException
{
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = null;
try
{
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/e_store");

Statement stmt = con.createStatement();

String insertCustomer = "Insert into Customers (Customer_ID,FName,LName,Address,Country,City,Telephone,Zipcode,EMail) " +
"Values( 'm + 1'," + "'" + FName + "','" + LName + "','" + Address + "','" + Country + "','" + City + "','" + Telephone +
"'" + FName + "','" + EMail + "');";

stmt.executeUpdate(insertCustomer);
stmt.close();
}
finally
{
if (con != null)
con.close();
}
}

}




and here my jsp page that uses the class

<%@ page import="java.util.Date, java.sql.*, java.util.*" %>
<%@ page contentType="text/html; charset=iso-8859-7" %>
<jsp:useBean id="newcust" class="estore.Customer" scope="page"/>
<jsp:getProperty name="newcust" property="ValidateFields"/>
<jsp:getProperty name="newcust" property="CreateCustomer"/>

"<"html">"
"<"head">"
"<"title">"���� ������� -- Registration"<"/title">"
"<"/head">"
"<"body">"

"<"%
if (request.getParameter("Submit") != null)
{
if (ValidateFields())
{
CreateCustomer();
}
}
%">"


 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tomcat returns that it didnt find the package estore
the .class files are in the class folder
what is the problem???
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when you use your own package to store your classes you have to create a directory with the exact name with the package inside the class directory, for instance :

you have to create : Tomcat/WEB-INF/classes/estore/
and store your Customer.class in there

try it and let me know ho's it going...
regards
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello friend,

You create your own directory like estore, so now put it under WEB-INF/classes/estore and then call it in your JSP page, hope it will work fine.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It finds the class finally
but know there is another problem
tomcat returns an error --> cant find information on ValidateFields
how do i use the methods of the .class file?
is it right?

thnx!!
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aris ,

didn't see full code but accessibility modifier of ValidateFields is private, change it to public it should solve your problem.

thanks
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:
Aris ,

didn't see full code but accessibility modifier of ValidateFields is private, change it to public it should solve your problem.

thanks



You'll also want to use JavaBean naming conventions for your methods.
Change ValidateFields to getValidateFields or isValidateFields. Then access with "property="validateFields".

The useBean and getProperty tags are not really designed for calling utility methods. They are designed for reading properties from beans in an MVC pattern. The controller should be a servlet.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i changed it to public but it gives me the same error!!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:


You'll also want to use JavaBean naming conventions for your methods.
Change ValidateFields to getValidateFields or isValidateFields. Then access with "property="validateFields".

The useBean and getProperty tags are not really designed for calling utility methods. They are designed for reading properties from beans in an MVC pattern. The controller should be a servlet.

 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can i do what you are saying
im not a pro in jsp and i need some help on that
if you can give me an example or something
it will really help me

thnx
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aris Doxakis:
how can i do what you are saying
im not a pro in jsp and i need some help on that
if you can give me an example or something
it will really help me
thnx



SimpleMVC at http://simple.souther.us uses jsp:useBean and jsp:getProperty tags in an MVC pattern.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aris Doxakis:
how can i do what you are saying
im not a pro in jsp and i need some help on that
if you can give me an example or something
it will really help me
thnx



SimpleMVC at http://simple.souther.us uses jsp:useBean and jsp:getProperty tags in an MVC pattern.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnx i will study them
if i have any questions im sure they will be answered

thnx again
 
keep an eye out for scorpions and black widows. But the tiny ads are safe.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic