JDBC JavaBean and JSP
I have a JavaBean where I am just trying to display information from MySQL database.
I keep getting a null output but should really get back 1 record.
Please advise what I am doing wrong because I have spent hours on this and I cant see what I did wrong:
package num;
import java.io.*;
import java.sql.*;
import java.util.*;
public class dbBean implements Serializable
protected transient String query;
protected transient String resultTable;
protected transient Connection conn;
public dbBean()
query = null;
resultTable = null;
conn = null;
public void setResultTable(String resultTable)
this.resultTable = resultTable;
public String getResultTable()
this.viewDatabaseTable();
return resultTable;
public void viewDatabaseTable()
executeDb(query);
public void executeDb(String query)
if(conn == null)
initializeDb();
try
Statement stmt = conn.createStatement();
ResultSet results = stmt.executeQuery("SELECT * from user where lastname = 'Jones'");
while(results.next())
results.getString("lastname");
stmt.close();
results.close();
conn.close();
catch (SQLException sqle)
sqle.printStackTrace();
public void initializeDb()
try
Class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost/myfirst?user=root&password=mypassword");
catch (SQLException sqle)
sqle.printStackTrace();
catch (ClassNotFoundException cnfe)
cnfe.printStackTrace();
}The JSP:
<%@ page import = "num.dbBean" %>
<jsp:useBean id="db" scope="session" class="num.dbBean">
</jsp:useBean>
<html>
<body>
<jsp:getProperty name="db" property="resultTable" />
<br>
data here
</body>
</html>If I put this in a scriplet it works and I can get back a record.
Please advise.
while(results.next())
results.getString("lastname");
}Well you are iterating through your result set, but you aren't doing anything with the value now are you?
String lastName = results.getString("lastname");
what do you do with this value now?
Where do you call setResultTable() from?
Similar Messages
-
I am new to Beans and JSP. I would like to know how I can 'get' the resultset and output to a JSP? It would have a few records and each record will have field1,field2 and field3.
My question again: How to continue from here in Beans? How to write the code in JSP? Can anyone guide me with some simple codes as I would not be able to understand advance codes.
Thanks.
public String Login(String inputDep) throws SQLException
String returnString = null;
String dbUserid = "sa"; // Your Database user id
String dbPassword = "" ; // Your Database password
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:test", dbUserid ,dbPassword);
Statement stmt = con.createStatement();
String sql= "select * from Product where dept = '"+inputDep+"'";
ResultSet rs = stmt.executeQuery(sql);You could also try to read the resultset in your bean.
like:
=========== Bean ===============
public class myClass
public AccountData Login(String name, String password)
AccountData data = new AccountData ();
data.setName (resultset.getString ("name"));
//other setter methods
return data;
// use inner class to store values
public class AccountData
AccountData ()
private String name = null;
//further attributes
pubilic String getName ()
return name;
void setName (String name)
this.name = name;
//further getter and setter
}=========== JSP ===============
<jsp:useBean id="myBean" scope="session" class="classes.BeanClass"/>
<% MyClass.AccountData data = myBean.Login (name, password); %>
Name : <%= data.getName () %>Note > means %> -
Hi
I'm new to Java Prog. I've been trying many days to come up with a JSP that works with a JavaBean to validate a login with a SQL server. I somehow still cannot make my beans work.
It's a very simple JSP login.html with 2 fields: userName and userPass.
This page will action to the checkLogin.jsp where all the connection to the beans take place. If successful, it will forward to the nextPage welcome.jsp.
Can anyone pls help with a simple solution? I'm a beginner after all.
Thanks in advance.Create a bean with one method that takes in two strings, username and userpass. This method checks against the datbase and simply returns a true if the combination exists in the database. Otherwise, flase.
In checkLogin.jsp, extract the parameters sent in from login.html. Call the method on the bean.
If false is returned, display an error message or redirect back to login.html.
If true is returned, create a session variable like "loggedIn" and set value of it to be "true" or something like that.
Then use redirect to the welcome.jsp.
welcome.jsp first checks to see if that session variable "loggedIn" exists. If it does, it proceeds, otherwise, display an error message and/or redirect to login.html.
A logout.jsp can be written in a similar way except it would remove the session variable "loggedIn" -
Hi
Does Sun or some other organization conduct any good workshops on Javabeans and jsp technology - hands on training like Microsoft products usually have. - Something like "devcon" ??
Some people from our workplace have to have some urgent training on these technologies. Thanks in advance.
SueThey sure do... http://courses.coreservlets.com/
Don't really know how much or how often they offer these courses though.. looks like the guy might be free to do something soon. But to be honest, these courses basically run through the book. If your programmers have a decent background in Java, I'd say you could just as easily get away with getting some books (Profession JSP - Wrox press is amazing). I learned JSP in about 3 days of solid cramming. -
i am wondering whats the "correct" or best way to connect to a DB using JavaBeans and using this in JSP pages?
i read abt creating a SQL "Helper" class that has some functions like connect etc... but i am thinking its a bit confusing...
if i have a function
public static Statement Connect() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:auction","","");
stmt = con.createStatement();
} catch (SQLException e) {
System.out.println("ERROR: SQLException occured!\n" + e.getMessage());
} catch (Exception e) {
System.out.println("ERROR: An Exception occured!\n" + e.getMessage());
return stmt;
}then i use it
Statement stmt = SqlHelper.connect();when i want to close the connection how do i do it? is it a must to close connections anyway?
or shld i do it the easy way, having the code
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:auction","","");
stmt = con.createStatement();on all JSP pages?
Thank youBalusC wrote:Do it in the data layer. Write DAO classes and SQL helper classes. Then let the business layer, the Servlet, interact with the data layer and let the presentation layer, the JSP, display the results.
And don't return a Statement, but a Connection. And yes, closing a Connection is a must, otherwise you're leaking resources which will cause your web application to crash due to a memory shortage.ya thats what i am trying to do... but how do i? like this? except i return a connection instead? and also, i shld return it by reference? mmm... in java isit like return &con?
package AuctionSystem;
import java.sql.*;
public class SqlHelper {
private static Connection con;
private static Statement stmt;
public SqlHelper() {
Connection con = null;
Statement stmt = null;
public static void Connect() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:auction","","");
stmt = con.createStatement();
} catch (SQLException e) {
System.out.println("ERROR: SQLException occured!\n" + e.getMessage());
} catch (Exception e) {
System.out.println("ERROR: An Exception occured!\n" + e.getMessage());
public static Connection getCon() {
return con;
public static Statement getStmt() {
return stmt;
public static void Close() {
con.close();
stmt.close();
public static String FormatString(String string) {
return "'" + string + "'";
}Edited by: iceangel89 on May 27, 2008 3:50 AM -
JDBC installation for servlets and jsp
Hello All,
I am trying to use JDBC for my web application. i have a book but not very detailed and cannot find a good search on google.
they have said that the ODBC-JDBC bridge driver comes with jdk1.2 or forward. and ask me to set up an ODBC data source. so i went in control panel/systems tab and then try to add SQL and then when click finish it asks me how to connect to sql server, i entered my usename and password but says connection failed.
This is my worst nightmare. please help so i can start building web application using servlets and jsp.Let me tell you right now, you have BORING nightmares.
-
An error when using JSP to activate connection between Javabean and MySQL
I just input two paramenters in the input.htm, then click button 'submit' to
run output.jsp, then activate adder.getSum(); This function is to add two
number, save the sum to the MySQL database, and return the sum. I think the
java code and jsp file are no problem. A guess it's the problem relating to
the servlet engine trying to talk to the Javabean. Should I set some
envirenment or other? Please take a look. If necessary, I will attach my jsp
and java codes later.
The error is as below:
Apache Tomcat/4.0.1 - HTTP Status 500 - Internal Server Error
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error)
that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException:
at org.apache.jasper.runtime.JspRuntimeLibrary.internalIntrospecthelper(JspRuntimeLibrary.java:273)
root cause org.apache.jasper.JasperException:
at org.apache.jasper.runtime.JspRuntimeLibrary.convert(JspRuntimeLibrary.java:184)
I just selected some. Thanks,Yes, I'd be curious to see your code. In principle that should work.
-chicagoJava -
Having problem implementin javabeans in JSP
here is my code:
<html>
<body>
<%@ page language="java" import="dbBean"\%>
<jsp:useBean id="dbBean" scope="request" class="dbBean" />
<%
dbBean.setUserID(request.getParameter("id"));
dbBean.setUserPass(request.getParameter("pass"));
dbBean.setFirstName(request.getParameter("fname"));
dbBean.setLastName(request.getParameter("lname"));
dbBean.setEmail(request.getParameter("email"));
%>
The result of the query is:
<table>
<tr>
<th>UserID </th> <th> UserPass </th> <th> FirstName </th><th>LastName
</th><th>Email </th>
</tr>
<%= dbBean.InsertInfo() %>
</table>
<p>
</body>
</html>
<html>
<head>
<title>Register New Users</title>
<SCRIPT LANGUAGE=JAVASCRIPT>
<!--//var correct = true
function checkData(){
if (document.FrmAdd.fname.value == ""){
alert("Please enter First Name!");
FrmAdd.fname.focus();
FrmAdd.fname.select();
return false; }
else if (document.FrmAdd.lname.value == ""){
alert("Please enter Last Name!");
FrmAdd.lname.focus();
FrmAdd.lname.select();
return false;
else if(document.FrmAdd.email.value == ""){
alert("You must type in an email address")
FrmAdd.email.focus()
FrmAdd.email.focus()
return false
//if the emailAddrs does not contain the @ symbol
else if(document.FrmAdd.email.value.indexOf('@')== -1){
alert("Your email address is missing an @ symbol")
FrmAdd.email.focus()
FrmAdd.email.focus()
return false
//if the emailAddrs does not contain a full stop
else if(document.FrmAdd.email.value.indexOf('.')== -1){
alert("Your email address is missing a period")
FrmAdd.email.focus()
FrmAdd.email.focus()
return false
else if (document.FrmAdd.id.value == ""){
alert("Please enter Login ID!");
FrmAdd.id.focus();
FrmAdd.id.select();
return false;}
else if (document.FrmAdd.pass.value == ""){
alert("Please enter Login Password!");
FrmAdd.pass.focus();
FrmAdd.pass.select();
return false;}
else if (document.FrmAdd.pass1.value == ""){
alert("Please enter Login Password!");
FrmAdd.pass1.focus();
FrmAdd.pass1.select();
return false; }
else if(document.FrmAdd.pass.value != document.FrmAdd.pass1.value){
alert("Both password doesnt match");
FrmAdd.pass1.focus();
FrmAdd.pass1.select();
return false;}
return true;
//-->
</SCRIPT>
</head>
<form name="FrmAdd" method="post" action="registration1.jsp" onSubmit="return checkData();">
<body>
<Center>
<table border="0">
<tr><td align="center">
<font face = "verdana" size ="4" color="darkblue"><b><I>Welcome to Registration Page</I></b></font>
</td><tr>
</table>
<table>
<tr>
<font face="verdana" size="1">Home</font>
<td bgcolor="#93bee2" style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"
colspan="2" align="middle">
<font Face="verdana" color="Darkblue" size="2">Registration</font></td>
</tr>
<tr></tr><tr></tr>
<tr>
<td bgcolor="#dbeaf5" style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"
colspan="2" align="middle">
<font Face="verdana" color="Darkblue" size="2">Profile</font>
</td></tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>First Name</b></font></td>
<td>
<input name="fname" size=23 maxlength=40 tabindex ="1" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" ></td>
</tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>Last Name</b></font></td>
<td>
<input name="lname" size=23 maxlength=40 tabindex="2" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" ></td>
</tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>Email Address</b></font></td>
<td>
<input name="email" size=17 maxlength=30 tabindex="3" style="FONT-SIZE: 8pt; WIDTH: 154px; FONT-FAMILY: Verdana; HEIGHT: 19px"></td>
</tr>
<tr>
<td style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"
colspan=2 align="middle"><hr color="#dbeaf5"></td>
</tr>
<tr>
<td bgcolor="#dbeaf5" style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px"
colspan=2 align="middle">
<font Face="verdana" color="Darkblue" size="2">Account Information</font>
</td>
</tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>Sign-in</b></font></td>
<td><input name="id" size=9 maxlength=9 tabindex="4" style="FONT-SIZE: 8pt; WIDTH: 128px; FONT-FAMILY: Verdana; HEIGHT: 19px"
></td>
</tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>Password</b></font></td>
<td> <input type="password" name="pass" size=25 maxlength=25 tabindex="5" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" ></td>
</tr>
<tr>
<td cellspacing="0" cellpadding="0" align="left"><font size="2"><b>Re-Enter Password</b></font></td>
<td>
<input type="password" name="pass1" size=25 maxlength=25 tabindex="5" style="FONT-SIZE: 8pt; FONT-FAMILY: Verdana" ></td>
</tr>
</table>
<table>
<tr>
<td cellspacing="0" cellpadding="0" align="middle">
<INPUT type=submit value="Signup" tabindex="9">
</td>
</tr>
</table>
</form>
</Center>
</body>
</html>
import java.sql.*;
import java.io.*;
public class dbBean{
private String dbURL = "jdbc:odbc:TheDataSourceName";
private String dbDriver = "sun:jdbc:odbc:jdbcOdbcDriver";
private Connection dbCon;
String UserID = null;
String UserPass = null;
String Email = null;
String FirstName = null;
String LastName = null;
public dbBean(){
super();
public String getUserID(){
return this.UserID;
public void setUserID(String UserID){
this.UserID = UserID;
public String getUserPass(){
return this.UserPass;
public void setUserPass(String UserPass){
this.UserPass = UserPass;
public String getEmail(){
return this.Email;
public void setEmail(String Email){
this.Email = Email;
public String getFirstName(){
return this.FirstName;
public void setFirstName(String FirstName){
this.FirstName = FirstName;
public String getLastName(){
return this.LastName;
public void setLastName(String LastName){
this.LastName = LastName;
public String connect(){
try
Class.forName(dbDriver);
return "Driver Loaded";
}catch(Exception E){
return "Unable to load Driver";
public String insertInfo(){
try{
dbCon = DriverManager.getConnection(dbURL);
PreparedStatement ps = null;
ps = dbCon.prepareStatement("Insert INTO Logins " +
" (userName, userPass, firstName, lastName, email) Values (?, ?, ?, ?, ?) ");
ps.clearParameters();
ps.setString(1, this.getUserID());
ps.setString(2, this.getUserPass());
ps.setString(3, this.getFirstName());
ps.setString(4, this.getLastName());
ps.setString(5, this.getEmail());
ps.executeUpdate();
ps.close();
dbCon.close();
return "Inserted row";
}catch(Exception e){
return "Error" + e.toString();
}//catch(SQLException e1){
//return "SQLException: " + e1.getMessage();
can anyone help me out i have paste my .jsp file, html file, and javabeans filei took out that line..now i'm getting this error:
i put all my .html and .jsp file under webapps\sgoyal
sgoyal is my folder name under webapps..
i put all of my .class files under webapps\sgoyal\WEB-INF\classes
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred at line: 3 in the jsp file: /registration1.jsp
Generated servlet error:
C:\unzipped\jakarta-tomcat-4.0.6\jakarta-tomcat-4.0.6\work\Standalone\localhost\sgoyal\registration1$jsp.java:60: Class org.apache.jsp.dbBean not found.
dbBean dbBean = null;
^
An error occurred at line: 3 in the jsp file: /registration1.jsp
Generated servlet error:
C:\unzipped\jakarta-tomcat-4.0.6\jakarta-tomcat-4.0.6\work\Standalone\localhost\sgoyal\registration1$jsp.java:63: Class org.apache.jsp.dbBean not found.
dbBean= (dbBean)
^
An error occurred at line: 3 in the jsp file: /registration1.jsp
Generated servlet error:
C:\unzipped\jakarta-tomcat-4.0.6\jakarta-tomcat-4.0.6\work\Standalone\localhost\sgoyal\registration1$jsp.java:68: Class org.apache.jsp.dbBean not found.
dbBean = (dbBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "dbBean");
^
3 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:285)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:536)
please help me out it's my first time i'm javaBean -
Problem with JavaBeans in JSP.IT'S URGENT!!!
Hi, i have problems with JavaBeans in JSP.
In a jsp file( locating in ROOT directory of tomcat 4.0.6 :jakarta-tomcat-4.0.6\webapps\root ) i have this code:
<jsp:useBean id="paramBean" class="licentza.ParamBean" />
<jsp:setProperty name="paramBean"
property="nume"
value='<%= request.getParameter("numeUser") %>' />
where ParamBean it's a "bean" class locating in jakarta-tomcat-4.0.6\webapps\examples\web-inf\classes\licentza (licentza is the package i'm using).
And i get this error:
Generated servlet error:
D:\jakarta-tomcat-4.0.6\work\Standalone\localhost\_\dora\intrare2$jsp.java:67: Class licentza.ParamBean not found.
ParamBean paramBean = null;
What is the problem?Thank you.Hi,
Put the class file or the package under :jakarta-tomcat-4.0.6\webapps\root\WEB-INF\classes.
Rajesh -
Using JavaBean with JSP...will not work no matter what
Hi guys. Sorry that this is such a common, newb question, but I don't know where else to turn.
I'm new to web application development, Tomcat, and JSP. I'm trying to use a simple JavaBean in a JSP to store some user information. The JSP is located in $CATALINA_HOME\webapps\art , and the UserBean I'm trying to use is in $CATALINA_HOME\webapps\art\WEB-INF\classes . I've tried adding a context in the Tomcat server.xml file, but nothing seems to work, even putting the .class file into the \art directory along with the JSP. The error I get is the following:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 1 in the jsp file: /welcome.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\art\welcome_jsp.java:43: cannot resolve symbol
symbol : class UserBean
location: class org.apache.jsp.welcome_jsp
UserBean user = null;
^
The source code is:
welcome.jsp
<%@ page import="java.sql.*" %>
<jsp:useBean id="user" class="UserBean" scope="session"/>
<html>
<head>
<title>Art Webapp Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<h1>Art Site</h1><br><br>
<h3>Welcome Page</h3><br><br>
<%
user.setUsername("joe");
user.setTitle("admin");
%>
</body>
</html>
UserBean:
public class UserBean {
private String username = null;
private String title = null;
public UserBean()
this.username = null;
this.title = null;
public String getUsername()
return this.username;
public String getTitle()
return this.title;
public void setUsername(String inName)
this.username = inName;
public void setTitle(String inTitle)
this.title = inTitle;
}//UserBean
Thanks for any and all help anyone could give me about this. It seems such a simple thing, to get a JavaBean working in a JSP...and it's very frustrating to have it NOT work when it seems I've done everything possible to get it to.Ok, I figured out what the problem was. My Bean was not a part of any specific package. It was never made clear to me that Beans are required to be a part of some package...I had no idea (though they always put them in packages in the tutorials, you think I would have picked up on it!).
So I just added the following line to the Bean:
package com.art;
Then compiled it and copied the .class file to CATALINA_HOME\webapps\art\WEB-INF\classes\com\art
Ta-da
Thanks for the help and sorry for taking up space on this board.
-Matt -
What is a javabean and how to compose it?
Q1:although have used many java class in jsp within tomcat, but i don't is it a standard javabean. I mean is any java class can be an javabean, or what is the different between javabean and java class.
for now i found some problem with 'javabean' used in jsp.
Q2:what is ther difference between use jsp:setProperty,jsp:getProperty and direct give value like 'myBean.variable=100'?
thanks!javabeans are standard classes but have :
- default constructor
- getter and setter methods
javabean can be used on custom tags, so no code on your jsp !
why don't directly use attributes ?
look this thread :
http://forum.java.sun.com/thread.jsp?forum=45&thread=314643
this is one, but it's not the only, reason.
Regards. -
Hello,
I am very new at this, and I am doing a very simple tutorial to use a JavaBean in JSP. I have followed all the procedures from my tutorial, and I get the following error:
org.apache.jasper.JasperException: Can't find a method to write property 'make' of type 'java.lang.String' in a bean of type 'com.wrox.cars.CarBean'
I have the bean:
package com.wrox.cars;
import java.io.Serializable;
public class CarBean implements Serializable {
private String make = "Ford";
public CarBean(){
public String getMake(){
return make;
public void SetMake(String make)
this.make = make;
and the JSP:
<jsp:useBean id="myCar" class="com.wrox.cars.CarBean" />
I have a <jsp:getProperty name="myCar" property="make" /><br>
<jsp:setProperty name="myCar" property="make" value="Ferrari" />
Now I have a <jsp:getProperty name="myCar" property="make" /><br>
The only thing I am missing is this step, where I have been looking for these JAR files and can't find them
I have downloaded many JSTL libraries, and still can't find them/
- dom.jar
- jaxp-api.jar
- jdbc2_0-stdext.jar
- sax.jar
- xalan.jar
- xercesImpl.jar
I really appreciate any help.Thanks a lot.
Although I should know that, it seems that the error was in the tutorial.
Thanks again, -
How to master good design with EJB and JSP?
I use JSP to calling EJB. But the .jsp file is complex and it's difficult to maintain...I just want to work higher efficent with EJB,JSP and JavaBean. I want to know is there a good design with EJB and JSP? and is there any good material about MVC for EJB,JSP and JavaBean?
You should read the J2EE blueprint available on this website. Better download the PDF, and print it for yourself so you can read it anytime.
-
WL vs. WL-express and JSP vs. javascript/SQL
folks-
i am trying to convince a certain party to
disband a web-based job tracking system being
written in ASP, javascript, html, css and SQL.
it will be hosted on MS webserver running NT.
i am trying to convince them to use JSP and
WL express. i have done two years of EJB
component work on weblogic, however, i have not
done work with JSP or thin-clients. i was mostly
business-logic.
anyway i have some questions and need some
direction. i already know JSP is better than
ASP/javascript etc. because:
* ASP is proprietary. ditto for VBscript
* with an IDE creating JSP is easy and JSP
automatically creates servlets which is way
faster than by hand
* JSP is JAVA based and hence benefits from
all the portability pluses of JAVA
but here are the more difficult questions:
* why is WL express better than an MS
web server? (not including WL market share
and size. after all MS can claim that)
* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding?* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
Use JDO or an OR-mapper or embed JDBC into your own data access classes.
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
Presentation=JSP
Logic=Servlet
Data access=JDO or similar
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
You should be able to tell up front if it a tx-intensive app that requires
WLS.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
They aren't exclusive. For dynamic pages, use Javascript on the front end,
JSP on the back.
* with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding?
In the real world, and for most apps, while Java has the architectural edge,
they both have similar scalability and similar robustness. MS gives you no
choice though, and you rewrite every time they see a new buzzword. You can't
leave MS-land without abandoning almost everything. You can leave WLS in a
week if you have to.
It's an investment. Invest wisely.
Peace,
Cameron Purdy
Tangosol, Inc.
Clustering Weblogic? You're either using Coherence, or you should be!
Download a Tangosol Coherence eval today at http://www.tangosol.com/
"shane miller" <[email protected]> wrote in message
news:[email protected]...
folks-
i am trying to convince a certain party to
disband a web-based job tracking system being
written in ASP, javascript, html, css and SQL.
it will be hosted on MS webserver running NT.
i am trying to convince them to use JSP and
WL express. i have done two years of EJB
component work on weblogic, however, i have not
done work with JSP or thin-clients. i was mostly
business-logic.
anyway i have some questions and need some
direction. i already know JSP is better than
ASP/javascript etc. because:
* ASP is proprietary. ditto for VBscript
* with an IDE creating JSP is easy and JSP
automatically creates servlets which is way
faster than by hand
* JSP is JAVA based and hence benefits from
all the portability pluses of JAVA
but here are the more difficult questions:
* why is WL express better than an MS
web server? (not including WL market share
and size. after all MS can claim that)
* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding? -
Dear all,
I am trying to do multinode installtion on AIX 5.3 HACMP . During post installation i am getting this error.
Dbc file and Jsp error
Updating Server Security Authentication
java.sql.SQLException: Io exception: Invalid number format for port number
Database connection to jdbc:oracle:thin:@host_name:port_number:database failed
Updating Server Security Authentication failed with exit code 1
adgendbc.sh exiting with status 1
ERRORCODE = 1 ERRORCODE_END
SQLPLUS Executable : /mglapp/oramgl/mglora/8.0.6/bin/sqlplus
SP2-0642: SQL*Plus internal error state 2165, context 4294967295:0:0
Unable to proceed
ERRORCODE = 1 ERRORCODE_END
Thanks in advanceMaybe you have problem with the date format, please ensure that NLS_DATE_FORMAT env variable is set to a valid value.
Please view SP2-0642: Sql*Plus Internal Error State 2165, Context 4294967295:0:0 Doc ID: Note:396154.1.
Hope it helps.
Adith
Maybe you are looking for
-
Hi, So what's the current situation with the MCIPT certifications in Windows 7? MCITP: Enterprise Desktop Support Technician on Windows 7 MCITP: Enterprise Desktop Administrator on Windows 7 The certifications had previously been scheduled to retire
-
How do I get the x-axis categories to lie at a diagonal, or veritcally, because my titles are very long and I can't have them lying horizontally next to each other.
-
How can I insert the copyright symbol
How can I insert the copyright symbol, I have tried the ALT + 0169 with no success. I want to include in a watermark brush
-
hiii..... i have 1 htree item on form....i have creted 1 recordgroup with query " select * from table1".... table having 3 columns... and have folowing code DECLARE htree ITEM; rg_data RECORDGROUP; BEGIN -- Find the tree itself. htree := Find_Item('t
-
User exit or badi for transaction PPOME
Hi, is there any user exit or Badi available when creating a relation between PD objects by means of transaction PPOME?. Best regards.