Servlet output to html table

Hi people,

I have a servlet which returns a bunch of data from a DB to a html page (see code below). It works fine, but id rather send this data to a jsp and render in a proper HTML table..Would look alot tidier this way. Im not too sure how to go about this as i dont use jsps much at all..Also I was told that it would be better to use vectors to contain all my objects. Can anyone help me out here or point me toward a good tutorial on how to do this kind of thing?

Thank you
oggiemc
out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
                  			" --- EMAIL --- DESCRIPTION --- COMPANY <br><br>");  
            	   stmt = con.createStatement();
            	   rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'" +
            				" AND LOCATION =  '"+thisLocation+"'" );  //Add chosen location to search criteria

            		 while(rs.next()){
            		  foundResults = true;
                       out.println( rs.getString("JOBID") + "---" + rs.getString("SECTOR") + "--- " +
                        rs.getString("LOCATION") + "--- " + rs.getString("SALARY") + "--- " + rs.getString("EMAIL")
                        + "--- "+rs.getString("DESCRIPTION") + "<br><br>"); 
            	          }
            		if(!foundResults){
            			out.println("Sorry, there are no " +" "+ thisSector +" "+ "vacancies in"+ " " +thisLocation+"." +
            		             		" "+ "Please go back and modify search."); 
            			
            		}}
                    catch (Exception e) {
            	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
            	      }

Open in new window

oggiemcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VenabiliCommented:
Ok - what is the problem in building the html table in the servlet? Just in the out.printlns instead of building strings and printing them, print the html itself

Any JSP will be compiled into a servlet anyway...

if you still require JSPs, we will need some more details (such as server that you use and so on) :)
0
oggiemcAuthor Commented:
Hi venabili,

I just thought that its tidier to embed html in a jsp than a servlet??would it not be very messy embedding a html table into a servlet? im using apache tomcat.
0
VenabiliCommented:
:) Tidy depends on the user that looks at it.

If you are more comfortable with servlets and you need a JSP only for this, the servlet will be good enough.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

oggiemcAuthor Commented:
ok, i may just leave it the way i have it then so!
0
VenabiliCommented:
:)

If you insist on jsps, check the tomcat documentation on how to start with them (or specify your tomcat version to give you a starting points).

But in this case - just rework the output of the servlet and you are all set.
0
objectsCommented:
yes servlets are not the best for rendering output.
approach you should use is to collect the data you need to renderer in your servlet then forward the request to you jsp for renderering

http://onjava.com/pub/a/onjava/excerpt/java_cookbook_ch18/index.html?page=8
0
objectsCommented:
displaytag is also great for displaying tables
http://displaytag.sourceforge.net/1.2/

as well as keeping html out of your servlet you also want to ensure you keep java code out of your jsp's
0
oggiemcAuthor Commented:
ok guys, thanks for all replies..First thing i wana do is use vectors to store my result set instead of working with strings..im trying the code below but im getting an error saying :

The constructor Object(String, String, String, String, String, String) is undefined

Can someone tell me how to fix this please?
public void JobSearch(String sector, String location, PrintWriter out) throws SQLException 			
	           {
		
              String thisSector = sector;
              String thisLocation = location;
              boolean foundResults = false;
              Vector<Object> v = new Vector<Object>();
    
               
           if(thisLocation.equals("Anywhere")) 
              try
      		   { 
            	out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
            			" --- EMAIL --- DESCRIPTION --- COMPANY <br>");    	
      		    stmt = con.createStatement();
      		    rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'");
    		    
      		     while (rs.next())
      		     {
      		    	 
                      String jobID = rs.getString("JOBID");
                      String Sector = rs.getString("SECTOR");
                      String Location = rs.getString("LOCATION");
                      String salary = rs.getString("SALARY");
                      String email = rs.getString("EMAIL");
                      String description = rs.getString("DESCRIPTION");
                    
                      Object obj = new Object(jobID, Sector, Location, salary, email, description);
                      v.add(obj);
                                           		    	 
      		     }
    		
      		   }
              catch (Exception e) {
      	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
      	   } 

	  }
}

Open in new window

0
objectsCommented:
create a bean class to store the row details eg.

  EmployeeBean obj = new EmployeeBean(jobID, Sector, Location, salary, email, description);


0
oggiemcAuthor Commented:
Thats a class using a constructor and accessor methods??
0
objectsCommented:
correct, having that will also make your jsp cleaner
0
oggiemcAuthor Commented:
so then would i have something like:

return v;

which would return to the calling environment, vectors of objects (as long as results were being retrieved from the database)??  would i call the method above from a jsp or what is the best way to link everything? sorry, im new to java..
0
rrzCommented:
Something like this.
public Vector JobSearch(String sector, String location, PrintWriter out) throws SQLException 			
	           {
              String thisSector = sector;
              String thisLocation = location;
              boolean foundResults = false;
              Vector<String> v = new Vector<String>();   
           if(thisLocation.equals("Anywhere")) 
              try
      		   { 
            	out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
            			" --- EMAIL --- DESCRIPTION --- COMPANY <br>");    	
      		    stmt = con.createStatement();
      		    rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'");
      		     while (rs.next())
      		     {	 
                      String jobID = rs.getString("JOBID");
                      String Sector = rs.getString("SECTOR");
                      String Location = rs.getString("LOCATION");
                      String salary = rs.getString("SALARY");
                      String email = rs.getString("EMAIL");
                      String description = rs.getString("DESCRIPTION");
                      v.add(jobID);
                      v.add(Sector);
                      v.add(Location);
                      v.add(salary);
                      v.add(email);
                      v.add(description);              		    	 
      		     }
      		   }
              catch (Exception e) {
      	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
      	   }
	  return v;
}

Open in new window

0
rrzCommented:

public Vector JobSearch(String sector, String location, PrintWriter out) throws SQLException 			
	           {
              String thisSector = sector;
              String thisLocation = location;
              boolean foundResults = false;
              Vector<String> v = new Vector<String>();   
           if(thisLocation.equals("Anywhere"))
             { 
              try
      		   { 
            	out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
            			" --- EMAIL --- DESCRIPTION --- COMPANY <br>");    	
      		    stmt = con.createStatement();
      		    rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'");
      		     while (rs.next())
      		     {	 
                      String jobID = rs.getString("JOBID");
                      String Sector = rs.getString("SECTOR");
                      String Location = rs.getString("LOCATION");
                      String salary = rs.getString("SALARY");
                      String email = rs.getString("EMAIL");
                      String description = rs.getString("DESCRIPTION");
                      v.add(jobID);
                      v.add(Sector);
                      v.add(Location);
                      v.add(salary);
                      v.add(email);
                      v.add(description);              		    	 
      		     }
      		   }
              catch (Exception e) {
      	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
      	   }
          }
	  return v;
}

Open in new window

0
oggiemcAuthor Commented:
hi rrz,

i thought the idea behind a vector was to add the objects and not the individual fields??
0
oggiemcAuthor Commented:
what i mean is..

you have:
                      v.add(jobID);
                      v.add(Sector);
                      v.add(Location);
                      v.add(salary);
                      v.add(email);
                      v.add(description);          
and i have:
                     
                      Object obj = new Object(jobID, Sector, Location, salary, email, description);
                      v.add(obj);

is it not tidier to add the object than adding individual strings??
           
0
objectsCommented:
>   would i call the method above from a jsp or what is the best way to link everything?

you would add the vector to the request and forward to the jsp

request.addAttribute("list", v);
request.getRequestDispatcher("/WEB-INF/jsp/list.jsp").forward(request, response);
0
Pramod KumarCommented:
See the sample codes:

=================
BEAN: JobVO.java 
=================
package mypack;

public class JobVO {
    String jobID;
    String Sector;
    String Location;
    String salary;
    String email;
    String description;

    public JobVO(String jobID, String Sector, String Location, String salary, String email, String description) {
        this.jobID = jobID;
        this.Sector = Sector;
        this.Location = Location;
        this.salary = salary;
        this.email = email;
        this.description = description;
    }

    public String getJobID() {
        return jobID;
    }

    public void setJobID(String jobID) {
        this.jobID = jobID;
    }

    public String getSector() {
        return Sector;
    }

    public void setSector(String sector) {
        Sector = sector;
    }

    public String getLocation() {
        return Location;
    }

    public void setLocation(String location) {
        Location = location;
    }

    public String getSalary() {
        return salary;
    }

    public void setSalary(String salary) {
        this.salary = salary;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}


=====================
SERVLET - Search.java
=====================
import mypack.JobVO;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.PrintWriter;
import java.io.IOException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.util.Vector;

public class Search extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String sector = request.getParameter("sector");
        String location = request.getParameter("location");
        Vector v = JobSearch(sector,location,out);

        request.setAttribute("alldata",v);
        request.getRequestDispatcher("searchresult.jsp").forward(request,response);
    }

    public Vector<JobVO> JobSearch(String sector, String location, PrintWriter out) {

        String thisSector = sector;
        String thisLocation = location;
        boolean foundResults = false;
        Vector<JobVO> v = new Vector<JobVO>();
        Statement stmt;
        ResultSet rs;
        Connection con;

        if (thisLocation.equals("Anywhere"))
            try {
                out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
                        " --- EMAIL --- DESCRIPTION --- COMPANY <br>");
                stmt = con.createStatement();
                rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='" + thisSector + "'");

                while (rs.next()) {

                    String jobID = rs.getString("JOBID");
                    String Sector = rs.getString("SECTOR");
                    String Location = rs.getString("LOCATION");
                    String salary = rs.getString("SALARY");
                    String email = rs.getString("EMAIL");
                    String description = rs.getString("DESCRIPTION");

                    JobVO obj = new JobVO(jobID, Sector, Location, salary, email, description);
                    v.add(obj);
                }
            }
            catch (Exception e) {
                out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
            }
        return v;
    }
}

========================
JSP - searchresult.jsp
========================
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="mypack.JobVO" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Vector v = (Vector) request.getAttribute("alldata");
%>
<html>
<head><title>Search Result</title></head>
<body>
<h1>Result</h1>
<hr>
<table border="1">
    <tr>
        <th>JOBID</th>
        <th>SECTOR</th>
        <th>LOCATION</th>
        <th>SALARY</th>
        <th>EMAIL</th>
        <th>DESCRIPTION</th>
    </tr>
    <%
        if (v != null) {
            Iterator it = v.iterator();
            while (it.hasNext()) {
                JobVO job = (JobVO) it.next();
                String jobID = job.getJobID();
                String Sector = job.getSector();
                String Location = job.getLocation();
                String salary = job.getSalary();
                String email = job.getEmail();
                String description = job.getDescription();
    %>
    <tr>
        <td>JOBID</td>
        <td>SECTOR</td>
        <td>LOCATION</td>
        <td>SALARY</td>
        <td>EMAIL</td>
        <td>DESCRIPTION</td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
</html>

Open in new window

0
Pramod KumarCommented:
Please replace the above JSP with this:
========================
JSP - searchresult.java
========================
<%@ page import="java.util.Vector" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="mypack.JobVO" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Vector v = (Vector) request.getAttribute("alldata");
%>
<html>
<head><title>Search Result</title></head>
<body>
<h1>Result</h1>
<hr>
<table border="1">
    <tr>
        <th>JOBID</th>
        <th>SECTOR</th>
        <th>LOCATION</th>
        <th>SALARY</th>
        <th>EMAIL</th>
        <th>DESCRIPTION</th>
    </tr>
    <%
        if (v != null) {
            Iterator it = v.iterator();
            while (it.hasNext()) {
                JobVO job = (JobVO) it.next();
                String jobID = job.getJobID();
                String Sector = job.getSector();
                String Location = job.getLocation();
                String salary = job.getSalary();
                String email = job.getEmail();
                String description = job.getDescription();
    %>
    <tr>
        <td><%=jobID%></td>
        <td><%=Sector%></td>
        <td><%=Location%></td>
        <td><%=salary%></td>
        <td><%=email%></td>
        <td><%=description%></td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
>i thought the idea behind a vector was to add the objects and not the individual fields??
I guess I misunderstood. Is this what you wanted ?  
public Vector JobSearch(String sector, String location, PrintWriter out) throws SQLException 			
	           {
              String thisSector = sector;
              String thisLocation = location;
              boolean foundResults = false;
              Vector<Vector> jobs = new Vector<Vector>();   
           if(thisLocation.equals("Anywhere"))
             { 
              try
      		   { 
            	out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
            			" --- EMAIL --- DESCRIPTION --- COMPANY <br>");    	
      		    stmt = con.createStatement();
      		    rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='"+thisSector+ "'");
      		     while (rs.next())
      		     {
	              Vector<String> job = new Vector<String>();
                      String jobID = rs.getString("JOBID");
                      String Sector = rs.getString("SECTOR");
                      String Location = rs.getString("LOCATION");
                      String salary = rs.getString("SALARY");
                      String email = rs.getString("EMAIL");
                      String description = rs.getString("DESCRIPTION");
                      job.add(jobID);
                      job.add(Sector);
                      job.add(Location);
                      job.add(salary);
                      job.add(email);
                      job.add(description); 
                      jobs.add(job);             		    	 
      		     }
      		   }
              catch (Exception e) {
      	     		out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
      	   }
          }
	  return jobs;
}

Open in new window

0
oggiemcAuthor Commented:
pramodkrjsr

Sorry for delay in reply, but the database i was using was down yeasterday and i couldnt get working on it until today..Thank you very much for the the detailed answer...I have a couple of questions..

 Why is the 2nd JSP saved as:

      ========================
JSP - searchresult.java
========================

I assume thats a typo.  Should it not be searchresult.jsp??
 At the moment im getting the following HTTP404 error when i call the Search servlet:

The requested resource (/FergalMc/servlet/searchresult.jsp) is not available...Any ideas whats wrong?? PS My html form is calling the Search servlet and not the searchresult.jsp so its nothing wrong with the form.

Thanks again for reply
0
Pramod KumarCommented:
Hello, Actually i have no idea what the flow you are using. My reply was based upon the attache image.
For HTTP404, please specify the location of your JSP if it is under some folder.
Example,
Deployed folder name: MyProj
Jsp path: MyProj/myjsp/searchresult.jsp

then, in servlet:
request.getRequestDispatcher("/myjsp/searchresult.jsp").forward(request,response);

map.JPG
project.JPG
0
oggiemcAuthor Commented:
I have the jsp file saved directly in the project folder i.e i do not have it in any sub folder..I changed the relative path and it is reading the jsp now, but im getting an http 500 stack trace error:

An error occurred at line: 21 in the generated java file
Type mismatch: cannot convert from List to Object

An error occurred at line: 40 in the generated java file
Type mismatch: cannot convert from searchresult_jsp to Object

Stacktrace:
      org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
      org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
      org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:349)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
      org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
      org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      Search.service(Search.java:64)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:404)
      org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:172)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Any ideas whats wrong with the code?

Thanks again
oggiemc
0
Pramod KumarCommented:
An error occurred at line: 21 in the generated java file
Type mismatch: cannot convert from List to Object


Means, wrong casting of data. Please attach your JSP
0
Pramod KumarCommented:
Also, the servlet from where you are calling  searchresult.jsp
0
oggiemcAuthor Commented:
hi pramodkrjsr,
Please see code below:
***********
Servlet
***********
import mypack.Object;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.PrintWriter;
import java.io.IOException;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.util.Vector;

public class Search extends HttpServlet {
	
	Connection con = null;
	Statement stmt = null;
	PreparedStatement pstmt;
	ResultSet rs = null;
	String JDBCUrl = "jdbc:oracle:thin:@136.206.35.131:1521:SSD";
	String username = "ee_user";
	String password = "ee_pass";
	
	

    public void connectToDB() {
		try {
			System.out.println("\nConnecting to the SSD Database......");
			Class.forName("oracle.jdbc.driver.OracleDriver");
			con = DriverManager.getConnection(JDBCUrl, username, password);
		} catch (Exception e) {
			System.out
					.println("An error has occurred during the connection phase! Did you upload your Oracle Drivers?");
		}

	}

	public void closeConnections() {
		try {
			if (rs != null)
				{rs.close();}
			if (stmt != null)
				{stmt.close();}
			if (pstmt != null)
				{pstmt.close();}
			if (con != null)
				{con.close();}
		} catch (Exception e) {
			System.out
					.println("<BR>An error occurred while closing down connection/statement");
		}
	}
	
	
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        String sector = request.getParameter("sector");
        String location = request.getParameter("location");
        Vector v = JobSearch(sector,location,out);

        request.setAttribute("alldata",v);
        request.getRequestDispatcher("/searchresult.jsp").forward(request,response);
  }
 
    
    public Vector<Object> JobSearch(String sector, String location, PrintWriter out) {

        String thisSector = sector;
        String thisLocation = location;
        boolean foundResults = false;
        Vector<Object> v = new Vector<Object>();
        Statement stmt;
        ResultSet rs;
        
        
        connectToDB();
        
        if (thisLocation.equals("Anywhere"))
            try {
                out.println("JOBID --- SECTOR --- LOCATION --- SALARY" +
                        " --- EMAIL --- DESCRIPTION --- COMPANY <br>");
                stmt = con.createStatement();
                rs = stmt.executeQuery("SELECT * FROM FMC_JOBS WHERE SECTOR ='" + thisSector + "'");

                while (rs.next()) {

                    String jobID = rs.getString("JOBID");
                    String Sector = rs.getString("SECTOR");
                    String Location = rs.getString("LOCATION");
                    String salary = rs.getString("SALARY");
                    String email = rs.getString("EMAIL");
                    String description = rs.getString("DESCRIPTION");	

                    Object obj = new Object(jobID, Sector, Location, salary, email, description);
                    v.add(obj);
                }
                closeConnections();
            }
            catch (Exception e) {
                out.println("<BR>An error has occurred during the Statement/ResultSet phase.");
            }
        return v;
    }
   
}

*******
JSP
*******

<%@ page import="java.util.Vector" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="mypack.Object" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Vector v = (Vector) request.getAttribute("alldata");
%>
<html>
<head><title>Search Result</title></head>
<body>
<h1>Result</h1>
<hr>
<table border="1">
    <tr>
        <th>JOBID</th>
        <th>SECTOR</th>
        <th>LOCATION</th>
        <th>SALARY</th>
        <th>EMAIL</th>
        <th>DESCRIPTION</th>
    </tr>
    <%
        if (v != null) {
            Iterator it = v.iterator();
            while (it.hasNext()) {
                Object job = (Object) it.next();
                String jobID = job.getJobID();
                String Sector = job.getSector();
                String Location = job.getLocation();
                String salary = job.getSalary();
                String email = job.getEmail();
                String description = job.getDescription();
    %>
    <tr>
        <td><%=jobID%></td>
        <td><%=Sector%></td>
        <td><%=Location%></td>
        <td><%=salary%></td>
        <td><%=email%></td>
        <td><%=description%></td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
</html>

Open in new window

0
objectsCommented:
don't include java code in your jsp
either use jstl or display tag library
0
rrzCommented:
>Any ideas whats wrong with the code?
>An error occurred at line: 21 in the generated java file
>Type mismatch: cannot convert from List to Object

>An error occurred at line: 40 in the generated java file
>Type mismatch: cannot convert from searchresult_jsp to Object  

>Object obj = new Object(jobID, Sector, Location, salary, email, description);    

You will have to choose a different name for your class.  
In the translated file(look in Tomcat's work folder),  _jspx_dependants and  the implicit variable "page"  have the apparent type of  Object.   Your class is conflicting with   java.lang.Object   .
0
Pramod KumarCommented:
Yea, you should use another name for the bean.
As in my example, i have created "Vector of Vector", so, either you follow the same or rename the bean (mypack.Object) to another name and use it as (Vector of Bean)
0
oggiemcAuthor Commented:
pramodkrjsr/anyone,

can you explain to me or direct me to a good link which explains packages. my only understanding of them is that they contain classes.  how do you define your own packages and why do you use them because im not too sure what they are used for..

many thanks for all the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.