Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse servlet/jsp webapp can't use java classes
Eclipse servlet/jsp webapp can't use java classes [message #662041] Tue, 29 March 2011 02:19 Go to next message
Benjamin  is currently offline Benjamin Friend
Messages: 5
Registered: March 2011
Junior Member
Hello,

I started making a brand new servlet/jsp web app in eclipse for my server which is using tomcat 7.0.10. I have 1 class, only one class, and no other class exists in this project. When I try to import this class into my JSP page, I get the error shown here:

http://www.bdbeasley.com/bdbeasley_ROOT/


Now, what I noticed is that even though I build my project, eclipse does not put my class files in WEB-INF/lib. So, I have to do it myself. If I don't put the class in there, then I get an error saying that tomcat can't find the classes, but if I put the classes into WEB-INF/lib and upload manually, I get an error that says tomcat thinks the class is a package! I know, its bizarre right? Why would it think my class is a package!

So obviously something here is screwy, but i don't know what... so uhhh... golden brownies to the fella who figures this one out.

header.jsp
<%@page import = "java.lang.Integer" %>
<%@page import = "manager.PageManager" %>
<%
	int iPageNumber = ((Integer) request.getAttribute("pageNumber")).intValue();
	iPageNumber--;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><%= PageManager.pageTitles[iPageNumber] %></title>
<link href = "resources/css/main.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<table align="center" width="610">
<tr>
	<td align="left">
		<h1>Benjamin D. Beasley</h1>
		<h2>Software Engineer</h2>
		<!-- MAIN TABS -->
		<ul  class = "navBar">	
			<%
				for(int i = 0; i < PageManager.pageTabTitles.length; i++)
				{
			%>
					<li class = "<%= (i == iPageNumber ? "selected" : "deselected") + " " + (i == 0 ? "first" : "") %>">
						<a href = "<%= PageManager.pageTabUrls[i] %>"><%= PageManager.pageTabTitles[i] %></a>
					</li>
			<%
				}
			%>
			<li class = "selected first" >
				<a href = "index.jsp">Portfolio</a>			
			</li>
			<li class = "deselected">
				<a href = "contact.jsp">Contact</a>			
			</li>
		</ul>
		<table id="mainTable" border="0" cellspacing="0" cellpadding="6" width="610">
			<tr>
				<td>

[Updated on: Tue, 29 March 2011 02:20]

Report message to a moderator

Re: Eclipse servlet/jsp webapp can't use java classes [message #662211 is a reply to message #662041] Tue, 29 March 2011 17:56 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

On 3/28/2011 10:19 PM, Benjamin wrote:
> I started making a brand new servlet/jsp web app in eclipse for my
> server which is using tomcat 7.0.10. I have 1 class, only one class, and
> no other class exists in this project. When I try to import this class
> into my JSP page, I get the error shown here:
> http://www.bdbeasley.com/bdbeasley_ROOT/
>
>
> Now, what I noticed is that even though I build my project, eclipse does
> not put my class files in WEB-INF/lib. So, I have to do it myself. If I
> don't put the class in there, then I get an error saying that tomcat
> can't find the classes, but if I put the classes into WEB-INF/lib and
> upload manually, I get an error that says tomcat thinks the class is a
> package! I know, its bizarre right? Why would it think my class is a
> package!
> So obviously something here is screwy, but i don't know what... so
> uhhh... golden brownies to the fella who figures this one out.

Standalone .class files are supposed to go into the WEB-INF/classes
folder. WEB-INF/lib is meant to contain jar files. You might want to
pursue this further, if needed, in the eclipse.webtools group.

--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Eclipse servlet/jsp webapp can't use java classes [message #662228 is a reply to message #662211] Tue, 29 March 2011 19:01 Go to previous messageGo to next message
Benjamin  is currently offline Benjamin Friend
Messages: 5
Registered: March 2011
Junior Member
Oh, you're right, they are supposed to go in web-inf/classes. Now I wonder why eclipse doesn't put them in web-inf/classes when you build the project. It would be really helpful if it did. Netbeans does that, and its really helpful. Does anyone know how to make ecliipse do that?
Re: Eclipse servlet/jsp webapp can't use java classes [message #662415 is a reply to message #662228] Wed, 30 March 2011 15:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NOSPAM.ibm.com

Hi,

That is done by the Web Tooling project from Eclipse. This isn't part of
the base Eclipse. If you don't have it installed, or if you didn't tell
it that the project is a WAR then it won't do that.

With the Web tooling installed you can tell it that a project is a WAR
and it will automatically do this for you.

In addition, the Web tooling allows you to start up and debug a server,
such as Tomcat, directly from your Eclipse IDE.

You should look into installing that. See:

http://www.eclipse.org/projects/project_summary.php?projecti d=webtools

--
Thanks,
Rich Kulp
Re: Eclipse servlet/jsp webapp can't use java classes [message #662537 is a reply to message #662415] Thu, 31 March 2011 02:17 Go to previous messageGo to next message
Benjamin  is currently offline Benjamin Friend
Messages: 5
Registered: March 2011
Junior Member
YOU, sir, are THE MAN.
Re: Eclipse servlet/jsp webapp can't use java classes [message #662542 is a reply to message #662415] Thu, 31 March 2011 04:23 Go to previous messageGo to next message
Benjamin  is currently offline Benjamin Friend
Messages: 5
Registered: March 2011
Junior Member
I'm having trouble finding out how to use WTP to make the project's classes be put in WEB-INF folder. There is no information on this subject. Can anyone help?
Re: Eclipse servlet/jsp webapp can't use java classes [message #662677 is a reply to message #662542] Thu, 31 March 2011 14:03 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NOSPAM.ibm.com

Hi,

There is a web tooling newsgroup.

The Web tooling home page gives you where to find info you need.

http://www.eclipse.org/projects/project_summary.php?projecti d=webtools

Info such as the newsgroup to use: eclipse.webtools

Or the documentation:

http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. wst.doc.user/topics/overview.html

--
Thanks,
Rich Kulp
Previous Topic:Annotations in Outline View, ..
Next Topic:eclipse doesn't construct web app correctly
Goto Forum:
  


Current Time: Thu Apr 18 23:50:52 GMT 2024

Powered by FUDForum. Page generated in 0.02357 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top