• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call a bean in a jsp ?

 
Shubha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
500 Internal Server Error
Java Server Page Translation Error
Error during compilation :
C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_examples\_jsp\_mob__off\_mobile2.java:102: cannot resolve symbol
symbol : class MyBean
location: class pagecompile.jsp._examples._jsp._mob__off._mobile2
MyBean order = null;
^
C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_examples\_jsp\_mob__off\_mobile2.java:105: cannot resolve symbol
symbol : class MyBean
location: class pagecompile.jsp._examples._jsp._mob__off._mobile2
order= (MyBean)
^
C:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_examples\_jsp\_mob__off\_mobile2.java:110: cannot resolve symbol
symbol : class MyBean
location: class pagecompile.jsp._examples._jsp._mob__off._mobile2
order = (MyBean) Beans.instantiate(getClassLoader(), "MyBean");
^
3 errors
<html>
<body>
<form name="form2" enctype="multipart/form-data" method="post" action = "mobile2.jsp">
<input type = "file" name = "filename">
<input type = "submit" value = "submit">
</form>
</body>
</html>
<%@ page language="java" import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.sybase.jdbcx.*" %>
<%@ page import="java.io.*" %>
<%
Connection con=null;
try
{
Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
con=DriverManager.getConnection("jdbc:sybase:Tds:10.112.96.86:6400/abc","sa1","");
}
catch(ClassNotFoundException e)
{
System.out.println(e);
}
catch(SQLException se)
{
System.err.println("SQL Exception caught:" + se);
}
System.out.println("Success 1");
%>

<HTML>
<BODY>
Hello Visualbuilder
<jsp:useBean class="MyBean" id="order" scope="page" />
<%= order.doUpload(request) %>
</BODY>
</HTML>
Please help to solve the problem
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make sure that MyBean is in the classpath for your application.
Also, it's worth upgrading to Apache Tomcat rather than using the Java Web Server since it is no longer supported and Tomcat is much more up to date.
Simon
[ November 13, 2002: Message edited by: Simon Brown ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also need to put your bean class in a package and specify the package in the <jsp:useBean tag AND import the package. This comes up so often it should be in a FAQ.
Here is why: when the compiler sees a reference to a class with no package (default package) it looks in the "current" directory. With servlet engines you have no control over the current directory, so the compiler won't find the class.
WBB
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic