File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Exception String array in Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception String array in Java?" Watch "Exception String array in Java?" New topic
Author

Exception String array in Java?

Kyupa Supa
Ranch Hand

Joined: Jun 23, 2012
Posts: 30
I have 3 sql tables: **professors(prof_id, name)**, **professors_courses(prof_id, course_id)** and **courses(course_id, title)**.

**professors_courses** is the bridge table between professors and courses.

In *CourseAssignments.java* I search which courses belong to professor x, after user enters a professor "name".





Method returns the course titles in a String array, that belong to professor x. I have problems with the array only.

For example:

In "professors" table we have prof_id: 5, name: John;
In professors_courses we have prof_id: 5, course_id: 1
prof_id: 5, course_id: 9
In "courses" table we have course_id: 1, title: French
course_id: 9, title: Spanish
User enters: "John"

In ArrayList "results" I store:
prof_id: 5, course_id: 1 and prof_id: 5, course_id: 9
So it's similar with the bridge table, but only contains the info regarding "John".

In String cs[] I want to store all the courses of John

In JSP:



titles[] should store all the courses so I can display them in a table, but I got exception:


org.apache.jasper.JasperException: An exception occurred processing JSP page /ComplexSearch/FoundS.jsp at line 8


Stacktrace:
.....................

root cause

java.lang.ArrayIndexOutOfBoundsException: 3


I call the method for "John" only just for testing. I'm not sure yet how I will request the name from user. I'm trying to make user choose the name by clicking on the name inside a html table.

Thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception String array in Java?
 
Similar Threads
Collections - ArrayList and Vector
javax.servlet.ServletException: javax.servlet.jsp.JspException: No getter method for property result
Number Format Exception
Display 2 ArrayLists in HTML table
Persistence Example