• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to call a bean in a jsp ?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic