You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Level, Haroldo (Jr)" <le...@hp.com> on 2006/08/22 15:45:31 UTC

Import user defined class not working


Hello all,

Im trying to import a class into a JSP file.

At the beginning I got the an error saying "Generated servlet error:
Only a type can be imported. SDTDeal resolves to a package"

After a lot of googling I found  I wasn't placing my class files in the
WEB-INF\classes\ directory and my classes weren't public. But after I
fixed all of that I got the following error:

"An error occurred at line: 113 in the jsp file: /SD Tool/CheckNew.jsp
Generated servlet error:
SDTDeal cannot be resolved"

I heven't find a way to solve this issue since the error message is too
general. Can somebody please give me some help at least to get me going
on to how to solve this problems.

P.S. Here is the JSP code:

 <%@ page import="java.sql.*" %>
 <%@ page import="java.io.*" %>
 <%@ page import="SDT.SDTDeal" %>


 

<%String connectionURL =
"jdbc:microsoft:sqlserver://HLEVEL1:1433;databasename=sdt";
Connection connection = null;
Statement statement = null;
PreparedStatement insert= null;
ResultSet rs = null;

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstanc
e();
connection = DriverManager.getConnection( connectionURL, "harol3",
"toto2409"); statement = connection.createStatement();

  
String user = request.getParameter("user"); String password =
request.getParameter("password"); String
name=request.getParameter("name");
String company=request.getParameter("company");
int day=Integer.parseInt(request.getParameter("day"));
int month=Integer.parseInt(request.getParameter("month"));
int year=Integer.parseInt(request.getParameter("year"));
String checkbox=request.getParameter("checkbox");
boolean fail=false;

if(name.trim().equals(""))
{
	fail=true;
	%>
	</p>
	<p><span class="style7">Fill in the name of the Deal </span></p>
	<p>
  	<%
}

else
{
	rs = statement.executeQuery("SELECT name FROM deals WHERE name
LIKE '"+name.trim()+"'");
	
	if(rs.next())
	{
		fail=true;
		%>
		</p>
		<p><span class="style7">This name is being used by
another deal </span></p>
		<p>
		 <%
	}
}

if(company.trim().equals(""))
{
	fail=true;
	%>
</p>
<p><span class="style7">Fill in the Company Name</span></p> <p>
  <%
}

if(checkbox==null)
{
	if((month==4||month==6||month==9||month==11)&&day==31)
	{
		fail=true;
		%>
		</p>
		<p><span class="style7">The selected month does not have
31 days</span></p>
		<p>
		  <%
	}
	
	if(month==2&&day>28)
	{
		fail=true;
		%>
		</p>
		<p><span class="style7">The selected month have less
than 29 days</span></p>
		<p>
		  <%
	}
	
}

if(fail)
{
	%>
	</p>
	<form action="New.jsp" method="post" name="form1"
target="rightFrame" class="style4" id="form1">
    <div align="left">
      <input type="hidden" value = "<%= user%>"name="username" />
      <input type="hidden" value = "<%= password%>"name="password" />
      <input type="submit" name="Submit" value="    Back    " />
    </form>
	<p>
	<%
}

else
{
	SDTDeal deal = new SDTDeal(day,month,year,company,name);
	
	try
	{
		ObjectOutputStream dout= new ObjectOutputStream(new
FileOutputStream(new File(name+".deal")));
		dout.writeObtect(SDTDeal);
	
		insert = connection.prepareStatement("INSERT INTO deals
VALUES ('"+name+"','"+company+"','IP','"+user+"')");
		insert.executeUpdate();
		%>
			</p>
			<p><span class="style7">New deal created
Successfully</span></p>
			<p>
		</p>
		<form action="Work.jsp" method="post" name="form1"
target="rightFrame" class="style4" id="form1">
		<div align="left">
		  <input type="hidden" value = "<%= user%>"name="user"
/>
		  <input type="hidden" value = "<%=
password%>"name="password" />
		  <input type="hidden" value = "<%= name%>"name="name"
/>
		  <input type="hidden" value = "<%=
company%>"name="company" />
		  <input type="submit" name="Submit" value="Go to first
evaluation" />
		</form>
		<p>
		<%
	}
	
	catch(Exception e)
	{
		e.printStackTrace();
	}
}
%>

Regards and your help is very welcome,
Haroldo Level Jr


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Import user defined class not working

Posted by "Level, Haroldo (Jr)" <le...@hp.com>.
Hello all,

The issue was solved. The error was not related to tomcat but to an error in the code that I missed, thanks Hassan for your help. And thanks everybody else for your sugestions I will look into them

Regards,
Haroldo Level

-----Original Message-----
From: Lou Caudell [mailto:lcaudell@wtceng.com] 
Sent: Tuesday, August 22, 2006 10:25 AM
To: Tomcat Users List
Subject: Re: Import user defined class not working

Markus Schönhaber wrote:
> Level, Haroldo (Jr) wrote:
>   
>> Im trying to import a class into a JSP file.
>>
>> At the beginning I got the an error saying "Generated servlet error:
>> Only a type can be imported. SDTDeal resolves to a package"
>>
>> After a lot of googling I found  I wasn't placing my class files in 
>> the WEB-INF\classes\ directory and my classes weren't public. But 
>> after I fixed all of that I got the following error:
>>
>> "An error occurred at line: 113 in the jsp file: /SD 
>> Tool/CheckNew.jsp Generated servlet error:
>> SDTDeal cannot be resolved"
>>     
> [...]
>   
>>  <%@ page import="SDT.SDTDeal" %>
>>     
>
> You should have
> WEB-INF\classes\SDT\SDTDeal.class
> Is that so?
> BTW: case matters.
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, 
> e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   
Looks like you're developing without using a good IDE. Not using one is actually more time consuming and difficult than using one for java web development. Besides you will pickup the structure more easily, and it will be in a portable .war file. I suggest Netbeans. It's free.
Also, look into MVC2 architecture, so you won't need to expose your db password. After all a jsp is a text file.

- Lou Caudell

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Import user defined class not working

Posted by Lou Caudell <lc...@wtceng.com>.
Markus Schönhaber wrote:
> Level, Haroldo (Jr) wrote:
>   
>> Im trying to import a class into a JSP file.
>>
>> At the beginning I got the an error saying "Generated servlet error:
>> Only a type can be imported. SDTDeal resolves to a package"
>>
>> After a lot of googling I found  I wasn't placing my class files in the
>> WEB-INF\classes\ directory and my classes weren't public. But after I
>> fixed all of that I got the following error:
>>
>> "An error occurred at line: 113 in the jsp file: /SD Tool/CheckNew.jsp
>> Generated servlet error:
>> SDTDeal cannot be resolved"
>>     
> [...]
>   
>>  <%@ page import="SDT.SDTDeal" %>
>>     
>
> You should have
> WEB-INF\classes\SDT\SDTDeal.class
> Is that so?
> BTW: case matters.
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   
Looks like you're developing without using a good IDE. Not using one is 
actually more time consuming and difficult than using one for java web 
development. Besides you will pickup the structure more easily, and it 
will be in a portable .war file. I suggest Netbeans. It's free.
Also, look into MVC2 architecture, so you won't need to expose your db 
password. After all a jsp is a text file.

- Lou Caudell

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Import user defined class not working

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
Level, Haroldo (Jr) wrote:
> Im trying to import a class into a JSP file.
>
> At the beginning I got the an error saying "Generated servlet error:
> Only a type can be imported. SDTDeal resolves to a package"
>
> After a lot of googling I found  I wasn't placing my class files in the
> WEB-INF\classes\ directory and my classes weren't public. But after I
> fixed all of that I got the following error:
>
> "An error occurred at line: 113 in the jsp file: /SD Tool/CheckNew.jsp
> Generated servlet error:
> SDTDeal cannot be resolved"
[...]
>  <%@ page import="SDT.SDTDeal" %>

You should have
WEB-INF\classes\SDT\SDTDeal.class
Is that so?
BTW: case matters.

Regards
  mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org