473,654 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Class files for jsp

I am using Jserv on apache and I cannot instantiate from a class file in
JSP.
I was using servlets before and any class I put in the same directory (or
other directories indicated with a classpath in the Jservproperties file)
would work fine. But JSP files (which are in a different directory) cannot
seem to find my classes no matter where I put them...whether in a classpath
or not. I even put them in the WEB_INF/classes folder and still nothing.
I have searched everywhere for an answer. Does anyone know???

H.Ellis Ensle

Jul 17 '05 #1
5 7974
Harold Ensle wrote:
I am using Jserv on apache and I cannot instantiate from a class file in
JSP.
I was using servlets before and any class I put in the same directory (or
other directories indicated with a classpath in the Jservproperties file)
would work fine. But JSP files (which are in a different directory) cannot
seem to find my classes no matter where I put them...whether in a classpath
or not. I even put them in the WEB_INF/classes folder and still nothing.
I have searched everywhere for an answer. Does anyone know???

Harold,

Perhaps you should post some sample code and describe the directory
structure of your WAR. One question comes to mind however: did you
import the desired classes with <@page import="" @> ?

Ray

Jul 17 '05 #2

"Raymond DeCampo" <rd******@spa m-I-am-not.twcny.rr.co m> wrote in message
news:Va******** *********@twist er.nyroc.rr.com ...
Harold Ensle wrote:
I am using Jserv on apache and I cannot instantiate from a class file in
JSP.
I was using servlets before and any class I put in the same directory (or other directories indicated with a classpath in the Jservproperties file) would work fine. But JSP files (which are in a different directory) cannot seem to find my classes no matter where I put them...whether in a classpath or not. I even put them in the WEB_INF/classes folder and still nothing.
I have searched everywhere for an answer. Does anyone know???

Harold,

Perhaps you should post some sample code and describe the directory
structure of your WAR. One question comes to mind however: did you
import the desired classes with <@page import="" @> ?

Ray


Thank you for the reply. This seems to be part of the problem. So I now have
something
like:

<%@ page import="ZClass" %>
<%
ZClass zc=new ZClass(1);
%>

The class itself has:

public class ZClass
{
ZClass(int x)
{
......
}
}

Now the JSP is acting like it finds the class (no error on the import)
but it is saying there is no constructor of the type to be found.
But I see a constructor there. What did I do wrong?

(I think Java hates me.)

H.Ellis Ensle
Jul 17 '05 #3
Harold Ensle wrote:
"Raymond DeCampo" <rd******@spa m-I-am-not.twcny.rr.co m> wrote in message
news:Va******** *********@twist er.nyroc.rr.com ...
Harold Ensle wrote:
I am using Jserv on apache and I cannot instantiate from a class file in
JSP.
I was using servlets before and any class I put in the same directory
(or
other directories indicated with a classpath in the Jservproperties
file)
would work fine. But JSP files (which are in a different directory)
cannot
seem to find my classes no matter where I put them...whether in a
classpath
or not. I even put them in the WEB_INF/classes folder and still nothing.
I have searched everywhere for an answer. Does anyone know???


Harold,

Perhaps you should post some sample code and describe the directory
structure of your WAR. One question comes to mind however: did you
import the desired classes with <@page import="" @> ?

Ray

Thank you for the reply. This seems to be part of the problem. So I now have
something
like:

<%@ page import="ZClass" %>
<%
ZClass zc=new ZClass(1);
%>

The class itself has:

public class ZClass
{
ZClass(int x)
{
......
}
}

Now the JSP is acting like it finds the class (no error on the import)
but it is saying there is no constructor of the type to be found.
But I see a constructor there. What did I do wrong?

(I think Java hates me.)


I would wager that the issue is that you didn't declare the constructor
public, like so:

public class ZClass
{
public ZClass(int x)
{
......
}
}

Java defines four access levels: public, protected, private and package
or default. Package level is the default that is used when no access
specifier is, well, specified. (IMHO, it would have been better to make
an explicit keyword for package level and require one.) Public,
protected and private behave as one would expect from other OO
languages. Package level defines an access level within a package; any
class within the same package can access the method, variable, etc.
This provides functionality similar to C++ friends. Note that unless
the package is sealed, nothing prevents others from creating classes in
the same package and exploiting the access, if you care about that sort
of thing.

Another interesting thing is that the access levels in descending order
are public, protected, package and private. That means that protected
implies package. Which means that you cannot have methods, variables
etc that are visible to the subclass but not to the other members of the
package. (IMHO, I would have preferred public, package, protected and
private; or even something not well-ordered where package and protected
are unrelated.)

Ray


Jul 17 '05 #4

"Raymond DeCampo" <rd******@spa m-I-am-not.twcny.rr.co m> wrote in message
news:F3******** **********@twis ter.nyroc.rr.co m...
Harold Ensle wrote:
"Raymond DeCampo" <rd******@spa m-I-am-not.twcny.rr.co m> wrote in message
news:Va******** *********@twist er.nyroc.rr.com ...
Harold Ensle wrote:

I am using Jserv on apache and I cannot instantiate from a class file inJSP.
I was using servlets before and any class I put in the same directory
(or
other directories indicated with a classpath in the Jservproperties


file)
would work fine. But JSP files (which are in a different directory)


cannot
seem to find my classes no matter where I put them...whether in a


classpath
or not. I even put them in the WEB_INF/classes folder and still nothing.I have searched everywhere for an answer. Does anyone know???
Harold,

Perhaps you should post some sample code and describe the directory
structure of your WAR. One question comes to mind however: did you
import the desired classes with <@page import="" @> ?

Ray

Thank you for the reply. This seems to be part of the problem. So I now have something
like:

<%@ page import="ZClass" %>
<%
ZClass zc=new ZClass(1);
%>

The class itself has:

public class ZClass
{
ZClass(int x)
{
......
}
}

Now the JSP is acting like it finds the class (no error on the import)
but it is saying there is no constructor of the type to be found.
But I see a constructor there. What did I do wrong?

(I think Java hates me.)


I would wager that the issue is that you didn't declare the constructor
public, like so:

public class ZClass
{
public ZClass(int x)
{
......
}
}

Java defines four access levels: public, protected, private and package
or default. Package level is the default that is used when no access
specifier is, well, specified. (IMHO, it would have been better to make
an explicit keyword for package level and require one.) Public,
protected and private behave as one would expect from other OO
languages. Package level defines an access level within a package; any
class within the same package can access the method, variable, etc.
This provides functionality similar to C++ friends. Note that unless
the package is sealed, nothing prevents others from creating classes in
the same package and exploiting the access, if you care about that sort
of thing.

Another interesting thing is that the access levels in descending order
are public, protected, package and private. That means that protected
implies package. Which means that you cannot have methods, variables
etc that are visible to the subclass but not to the other members of the
package. (IMHO, I would have preferred public, package, protected and
private; or even something not well-ordered where package and protected
are unrelated.)

Ray


Thanks. This was very informative. Using public worked. However, when
I used the class from a compiled servlet, it worked without "public" and
that
is why I didn't think it was needed. Apparently the compiler had public as
the default.

H.Ellis Ensle

Jul 17 '05 #5
Harold Ensle wrote:


Thanks. This was very informative. Using public worked. However, when
I used the class from a compiled servlet, it worked without "public" and
that
is why I didn't think it was needed. Apparently the compiler had public as
the default.


It is unlikely that the compiler "had public as the default." That
would violate the Java Language specification. More likely was that the
servlet was in the same package as the other class. (Probably both were
in the "default" package that classes without a package directive are
placed in.) That would give it access to anything declared without an
explicit access modifier.

Ray

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3281
by: Hal Vaughan | last post by:
My first Java project has gotten to the point where there are so many .java and .class files that I'd like to keep them separated so I can easily keep files straight. I have my /home/me directory and I want to put my .java files in /home/me/src and my class files in /home/me/bin. For now, I'm keeping the .java files in /home/me/src and, after I compile a class, I do "mv src/*class bin/" to transfer the newly generated .class files into...
2
2608
by: Harold Ensle | last post by:
Has anyone ever had this problem? I have been compiling servlet files, correcting them, recompiling them and seeing the changes on the next URL request. So everything was going smoothly. Suddenly I could no longer change the .class files. That is, they were changed but the URL was apparently calling a cached version which would not update. When Apache was restarted, it would then finally update. Needless to say this is very undesirable...
7
12960
by: A_StClaire_ | last post by:
hi, I'm working on a project spanning five .cpp files. each file was used to define a class. the first has my Main and an #include for each of the other files. problem is my third file needs to access the class defined in my second file and I can't figure out how to work this right. if I use an #include in my third file, my Main gives me a compile-time class redefinition error. if I don't, the third file can't "see" the second
14
7319
by: Mick | last post by:
I wrote a C# program that interfaces with a data vendor over the web using an API they supplied and their examples in C#. Now I have another data vendor's API and example that I want to add to my C# program. But this new API is written in Java. They gave me an example source code that uses their API but the actual API looks like it is stored in a few .jar files. I unzipped those .jar files into many .class files. I think these .class...
16
2637
by: pawel.pabich | last post by:
Hajo, I would like to have 2 my own partial classes. For example: Default.aspx.cs Default2.aspx.cs and they both will relate to Default.aspx page.
11
41075
by: Kimmo Laine | last post by:
I'm flipping my wig here, people. I'm using classes and making each class a file. when I'm including dependet classess, I use require_once to avoid multiple declarations - yet they happen. I put debug_print_backtrace in the file to see how it is included, and here's the output: #0 require_once() called at #1 require_once(\eKirje.textGrid.class.php) called at #0 require_once() called at #1 require_once(\eKirje.kanava.class.php)...
0
6603
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with every the of C++ project I try to build. Not just Class Libraries, but a plain Windows Form Application as well. I've tried creating new projects with nothing but shell built by the Wizard, but I still get the error.
32
5803
by: Matias Jansson | last post by:
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many classes in a Python module/file. What is the motivation behind it, would it be a bad idea to have a guideline in your project that promotes a one class per file structure (assuming most of the programmers a background similar to mine)?
5
5478
by: Marcin Gil | last post by:
Hi! I have the code like this (obvious things like ctor/dtor removed) typedef struct _NODE { int val; int index; } Node;
2
14894
by: yalbizu | last post by:
#include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; const int NO_OF_STUDENTS=20; struct studentType { string studentFName; string studentLName;
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.