i am new in jsp.i am trying to use useBean in jsp to run a class named hi.
i am using apache tomcat as a web server.i placed the file hi.class as well as the file that i named it date.jsp which uses the hi class in the folder webapps
the code of date.jsp is:

JSP Syntax (Toggle Plain Text)

<%@ page import="java.util.*" %><%@ page import="java.lang.*" %><HTML><BODY><jsp:useBean id=“my” scope="request" class=“hi”><jsp:getProperty name="my" property="*"/></jsp:useBean><%my.print()%;></BODY></HTML><%@ page import="java.util.*" %>
<%@ page import="java.lang.*" %>
<HTML>
<BODY>
<jsp:useBean id=“my” scope="request" class=“hi”>
<jsp:getProperty name="my" property="*"/>
</jsp:useBean>
<%my.print()%;>
</BODY>
</HTML>

the code of hi.class is:

import java.lang.*;import java.util.*;public class hi{public static int print(){System.out.println("hi");return 1;}public static void main(String args[]){System.out.println(print());}}import java.lang.*;
import java.util.*;
public class hi{
public static int print()
{System.out.println("hi");
return 1;
}
public static void main(String args[])
{System.out.println(print());
}
}

i am getting this error when i run date.jsp in web browser:
org.apache.jasper.JasperException: /date.jsp(5,17) quote symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:222)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:162)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:153)
org.apache.jasper.compiler.Parser.parseUseBean(Parser.java:953)
org.apache.jasper.compiler.Parser.parseStandardAction(Parser.java:1136)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1449)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:239)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:197)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:365)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:345)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:594)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:341)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


note The full stack trace of the root cause is available in the Apache Tomcat/7.0.5 logs.

apreciate any help
thanx

Take a look at this:

<%my.print()%;>

The quote is in the wrong place. The idea is that you write java code inside the <% .. %>

Inside a JSP page:

<%
int a = 0;
a = my.print();
%>

<!-- This is not java. It is displayed at the page: -->
Result: <%= a %>

<!-- OR -->
Result: <%= my.print() %>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.