aspose file tools*
The moose likes JSP and the fly likes JSP compile error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP compile error" Watch "JSP compile error" New topic
Author

JSP compile error

Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hello,
Am trying to call to JavaBean from JSP. I use the following code
<jsp:useBean id = "help1" scope = "request" class = "SpellCheck" />
<jsp:setProperty name = "help1" property = "*" />

It throws the following error:
Tue Apr 23 13:30:44 SGT 2002:<E> <ServletContext-General> Compilation of D:\weblogic51\myserver\classfiles\jsp_servlet\_wordpro.java failed: D:\weblogic51\myserver\classfiles\jsp_servlet\_wordpro.java:72: cannot resolve symbol
symbol : class SpellCheck
location: class jsp_servlet._wordpro
SpellCheck help1 = (SpellCheck) //[ /wordpro.jsp; Line: 1]
^
D:\weblogic51\myserver\classfiles\jsp_servlet\_wordpro.java:72: cannot resolve symbol
symbol : class SpellCheck
location: class jsp_servlet._wordpro
SpellCheck help1 = (SpellCheck) //[ /wordpro.jsp; Line: 1]
^
D:\weblogic51\myserver\classfiles\jsp_servlet\_wordpro.java:78: cannot resolve symbol
symbol : class SpellCheck
location: class jsp_servlet._wordpro
help1 = (SpellCheck) java.beans.Beans.instantiate(getClass()
.getClassLoader(), "SpellCheck"); //[ /wordpro.jsp; Line: 2]
^

Could anyone help me out with the solution.
Thanks in advance,

Mahesh
Sam Cala
Ranch Hand

Joined: Jan 03, 2001
Posts: 147
You need to make sure if the names of all the properties in the SpellCheck bean matches to that of Paramters coming from HTML.
Otherwise, specifically mention the name of the property whose value you want to set in the bean instead of '*'.


Best wishes,
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi Sam,
Checked both the bean and jsp, but cannot find any error. Can u pls debug it for me.
HTML(word.html):
<HTML>
<HEAD>
<TITLE> Word check</TITLE>
</HEAD>

<BODY>
<FORM METHOD = "GET" ACTION = "wordpro.jsp">
<INPUT type = "text" name = "word">
<select name ="mode">
<option value = "1" selected> Reverse</option>
<option value = "2"> SpellCheck</option>
<input type = "SUBMIT" name = "Go">
</FORM>
</BODY>
</HTML>
JSP(wordpro.jsp):
<jsp:useBean id = "help1" scope = "request" class = "SpellCheck" />
<jsp:setProperty name = "help1" property = "word" />
<html>
<body>
You entered , <b> <%= request.getParameter("word") %></b> <br>
<% System.out.println("The word is "+request.getParameter("word")); %>
Processes O/P is :<br>
<%= Integer.parseInt(request.getParameter("mode"))==1?help1.reverse():help1.check() %>
</body>
</html>

BEAN(SpellCheck.java):
public class SpellCheck{
private String word;

public SpellCheck(){
System.out.println("Here in the SpellCheck************************************");
}

public String reverse(){
return (new StringBuffer(word).reverse()).toString();
}

public boolean check(){
return true;
}

public String getWord(){
return word;
}

public void setWord(String aWord){
word = aWord;
}
}
Can u pls help?
Thanks,
Mahesh
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Have u imported the classes which r being used in the page.


Groovy
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Originally posted by pradeep bhat:
Have u imported the classes which r being used in the page.

Hi,
Is there a need to import the classes. It should be enough if the class file is placed in the proper location. BTW this is an example specified in the "Professional JSP" book which is a standard book.
They haven't imported the classes. The examples are specified on pages 46-47.

Mahesh
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I guess u r using weblogic. u need to import the classes.
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Originally posted by pradeep bhat:
I guess u r using weblogic. u need to import the classes.

Hi Pradeep,
Yeah u guessed right...Have imported the classfile...but can u pls clarify the reason...Still confused why 2 import???
Mahesh
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

visit http://www.coderanch.com/t/65308/BEA-Weblogic/useBean-JSP.
I will try ur question to the best of my knowledge.When jsp's are compiled into servlet they will found in some other temporary directory.
And that dir does not contain ur class files. So compilation will fail unless u explicitly import the classes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP compile error