• 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

Error in jsp on instanciating a java class

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
This is the first time I'm attempting to instantiate a java class inside of a jsp page. My java class compiles without errors. At the top of the class I do have a package statement and I do import the class implicitly into the jsp page, but when I try to do

MyClass myclass = new MyClass();

inside of my jsp page, I get an error "MyClass cannot be resolved to a type". I have no idea what's wrong, but it sounds like could be something very basic. Could anybody please give me some pointers for this error?
Thanks in advance.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the relevant code from the JSP. (Be sure to use UBB code tags to preserve the formatting).
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do you "implicitly" import a class in your jsp?
without an import tag for the specific class, it won't work
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I decided to create a java bean and attempt to import the EpisDBUtil class into the bean instead of a jsp file. Both, the bean and the EpisDBUtil (java and class files) are in the same folder "beans". Both java files contain the same package statement. When I compile the EpisSelectBean, I get the same error I was getting earlier:"EpisSelectBean cannot be resolved to a type". Please Help!
Here is how my EpisSelectBean bean:

Here is how my EpisSelectBean bean:

package jsps.beans;

import jsps.*;
import java.util.*;
public class EpisSelectBean implements java.io.Serializable{
private EpisDBUtil episdb;

public EpisSelectBean(){}

}
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
lilya,

I asked you to do two thing, neither of which you did.

First, please show us the relevant JSP code. The bean code is rather less helpful.

Secondly, when posting code on the Ranch, please use the UBB code tags to preserve formatting. It is incredibly hard to read unformatted code and many people will not bother. Please read this. You have been posting on the Ranch long enough to learn how to use it effectively.
[ November 06, 2006: Message edited by: Bear Bibeault ]
 
liliya woland
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what UBB tags are,
but the jsp code is very basic:

<%@ page import="java.io.*, java.util.*, myjsps.*" %>
<%
EpisDBUtil episdb = new EpisDBUtil();
%>

I store my files in webapps/myjsps. I was able to fix the errors in jsp file (what's above works fine), but but still get same errors in java files.
I think the errors have to do with configuration files...
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On UBB code, its simple enough. When you are editing a message you will see a bunch of buttons underneath the editor in a section labelled "Instant UBB Code" One of those buttons is "CODE"
Simply select the text in the textarea, and push the "CODE" button. (Works on IE, don't know about firefox)
Or you can just manually write [ CODE] and [ /CODE] around the bits you want to do as "code" (remove the space to so that it renders correctly)

It should end up looking something like this:



Note also I added an import statement for the package where your bean was.
Also your beans should be deployed under the WEB-INF/classes directory

ie the class EpisSelectBean should be compiled to the file
[webappname]/WEB-INF/classes/jsps/beans/EpisSelectBean.class

Cheers,
evnafets
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by liliya woland:
I'm not sure what UBB tags are,



I provided a link in my reply that has a detailed explanation. Do you even bother to read what people write?
 
Stefan Evans
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I provided a link in my reply that has a detailed explanation. Do you even bother to read what people write?


It seems that I don't, and just waste more of my time
 
reply
    Bookmark Topic Watch Topic
  • New Topic