File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to call a bean in a jsp ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to call a bean in a jsp ?" Watch "How to call a bean in a jsp ?" New topic
Author

How to call a bean in a jsp ?

Shubha
Greenhorn

Joined: Aug 31, 2002
Posts: 9
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

Joined: May 10, 2000
Posts: 1913
    
    6
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

Joined: Mar 22, 2000
Posts: 12681
    
    5
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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call a bean in a jsp ?
 
Similar Threads
getting-> 500 Internal Server Error
jsp beans internal server error 500
Can resolve symbol request
Integer.parseInt
HELP HELP !!! JSP-BEAN