aspose file tools*
The moose likes JSP and the fly likes Code not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Code not working

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Hi friends ,
I am currently printing simple HELLO WORLD !! using bean.. but it is giving the error in import that . expected;
my code goes here:

HelloBean.java


public class HelloBean {
private String name = "World";

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}
}

hello.jsp
<%@ page import="HelloBean" %>

<jsp:useBean id="hello" class="HelloBean">
<jsp:setProperty name="hello" property="*" />
</jsp:useBean>

<HTML>
<HEAD><TITLE>Hello</TITLE></HEAD>
<BODY>
<H1>
Hello, <jsp:getProperty name="hello" property="name" />
</H1>
</BODY>
</HTML>


error :
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\jakarta-tomcat-5.0.18\work\Catalina\localhost\HelloBean\org\apache\jsp\hello1_jsp.java:6: '.' expected
import HelloBean;
^
1 error

I dont know why is this simple error coming...any comments on what should be done.. i have check the hierarchy and all in webapps that fine..
so i would for ur replies on this
Thanks,
Saurabh
[ May 21, 2004: Message edited by: Bear Bibeault ]

Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

This is a recording: place your bean in a package other than the default.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Originally posted by Bear Bibeault:
This is a recording: place your bean in a package other than the default.


Thanks Bear,
I have done as what you said .. in the HelloBean.java i added package HelloBean; at the top but after hat following is the scene and the code is still not working:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: HelloBean (wrong name: HelloBean/HelloBean)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:256)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NoClassDefFoundError: HelloBean (wrong name: HelloBean/HelloBean)
java.lang.ClassLoader.defineClass0(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:537)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1677)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:900)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1350)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1230)
org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:120)
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1051)
org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1079)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2230)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2236)
org.apache.jasper.compiler.Node$Root.accept(Node.java:485)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2180)
org.apache.jasper.compiler.Generator.generate(Generator.java:3253)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:456)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

Tell me whats the problem .. this is so simple and stil i cant go ahead with it.
Hoping to hear from you soon.
Thanks
Saurabh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

Since Saurabh re-asked this question in a new post, I am closing this topic.

Saurabh, please do not open a new topic with the same question. Continue the discussion in the first topic you open.

bear
JSP Forum Bartender
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code not working