Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP compile error

 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 '*'.
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have u imported the classes which r being used in the page.
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess u r using weblogic. u need to import the classes.
 
Mahesh Mamani
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic