Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: bizzare error in a jsp file


Message #1 by "davo jones" <optimation@h...> on Fri, 16 Mar 2001 11:23:33
I have a jsp file that accesses some classes which return a vector of Job 
objects. When i try to print out the Job object without referencing a 
method e.g. out.println(job); it is ok and prints: Job@6... but when i 
try to reference a method eg out.println(job.title()); i get an error.
It works fine when i am not using a jsp, but in a jsp i am getting a 
problem. I have attatched the code below, can anyone help?

Thanks.


<%@ page buffer="96kb" autoFlush="true" 
errorPage="errorpage.jsp" %>

<jsp:useBean id="site" scope="session" class="SiteAnalyser" />
	<% 
	   site.setSearchString(request.getParameter("search"));
           String searchlevel = request.getParameter("level");

           if(searchlevel.equals("1"))
             site.setSearchLevel(1);

           else if(searchlevel.equals("2"))
 	     site.setSearchLevel(2);

	   site.siteConnector();
           Vector results[] = site.getSearchData();

	   int no = 0;
	   int sizecheck[] = new int[4];	   

	   for(int count = 0; count < 4; count++)	
	   {    
		   sizecheck[count] = results[count].size();	

		   if(sizecheck[0] < 1 && sizecheck[1] < 1 && sizecheck[2] 
< 1 && sizecheck[3] < 1)	
		   	 no = 1;	
				
           }
	 	
      %>
 
<html>
<head>
<title>jobIT.com - Search results for '<%= request.getParameter("search") %
>'</title>
</head>

<body bgcolor="#808080" text="#FFFFFF" vlink="#3399FF" alink="#0099FF" 
link="#3399FF">

<div align="center">
  <table border="0" cellpadding="0" cellspacing="0" width="450" 
height="265">
    <tr>
      <td width="450" height="137">
        <p align="center"><img border="0" src="images/logo.jpg" 
width="450" height="135"></td>
    </tr>
    <center>
    <tr>
      <td width="100%" background="images/back.jpg" height="34">
        <p align="center"><font face="Arial" size="2"><a 
href="index.html">Home</a>
        | <a href="help.html">Help</a>
        | <a href="contact.html">Contact</a>   <a 
href="info.html"><br>
        </a><img border="0" src="images/line.jpg" width="450" 
height="2"></font></td>
    </tr>
    <tr>
      <td width="100%" background="images/back.jpg" height="94" 
valign="top" align="left">
        <p align="center"><font face="Arial" size="2">

	<%
	if(no == 1)
	{
		
	%>
	<font face="Arial" size="2">Sorry, no results for that search. Try 
again.<p>
	</font>
        <form method="POST" action="searchresults.jsp">
        
          <p align="center"><font size="2" face="Arial">Quick Search on 
Title
          (Enter skills, e.g. Java)</font><input type="text" name="search" 
size="20">
          <input type="hidden" value="1" name="level">
              <input type="submit" value="Go!" name="B1"></p>
        </form>
        <p align="center"><font face="Arial" size="2"><a 
href="advancedsearch.html">Advanced
        Search</a></font>
	<%
	}	
	%>

	<%
	if(no == 0)
	{

	%>

         Results from search for: <b>'<%= request.getParameter("search") %
>'</b>
         <p>
	<center>To have these results e-mailed to you,<br> 
	enter your e-mail address:
	<form method="POST" action="mailer.jsp">

	<input type="text" name="email" size="20">

        <%
		   		
	   int counter = 0;
	   int upperb = 0;
	   int sitetrue[] = new int[4];

	   for(int count0 = 0; count0 < 4; count0++)	
	   {
		if(sizecheck[count0] > 0)
	        {
			upperb++;
			sitetrue[count0] = count0;
                }
           }
	   	

	   for(int count1 = 0; count1 < upperb; count1++) 
	   {
		for(int t = 0; t < results[sitetrue[count1]].size(); t++)
    		{
			 Job job = (Job)results[sitetrue[count1]].elementAt
(t);

	%>
		    	<input type="hidden" value="<%= job.title() %>" 
name="<%= counter %>">
		
	<% 
		      counter++;

	    	}
	   }	
	%> 

	<input type="hidden" value="<%=counter%>" name="number">	

   	 <input type="submit" value="Go!" name="B1"></p>
        </form>
	
	</center>
	 <p>

	  <%
        	
 		
          	for(int count = 0; count < 4; count++)
        	{

	             for(int i = 0; i < results[3].size(); i++)
	             {
				Job j = (Job)results[3].elementAt(0);
				
			       
				Job job = (Job)results[count].elementAt(i);
                 	       out.println(job.title());
	   %>
		<P>

	   <%
			       out.println(job.link() );

        	     }
	         }
	}
	   %>

	</font></td>
    </tr>
    </table>
  </center>
</div>

</body>

</html>

  Return to Index