Here is a screen shot of my project thus far:
The purpose of this program is too find specific classes from an ArrayList that I have in my servlet. You search for the classes you want from what you have defined on the left (i.e. a class in X location, and Y semester, and Z teacher). So far using this code, I can retrieve every single class as displayed in the screen shot:
Scripting:
//Serves up the data THIS IS THE WHAT GETS THE TABLE DATA
$('#btnData').click(function() {
$("#searchAnimation").fadeTo(0,1, function(){
$.get('daoServlet', function(responseText) {
$('#dataDisp').html(responseText);
}).complete(function(){$("#searchAnimation").fadeTo(0,0);});
});
});
Java:
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//String that gets returned as HTML
StringBuilder returnAsHTML = new StringBuilder();
//See if the class is closed, has a lab, or is just a regular class
for(ClassInfo classes : allClassListings)
{
//Class is full, style accordingly
if(classes.getSectionMeetingInfo().contentEquals("LEC") && classes.getSectionEnrolled().contentEquals("0"))
{
returnAsHTML.append(closedClass(classes));
}
else if(classes.getSectionMeetingInfo().contentEquals("LAB")) //These are labs, style accordingly
{
returnAsHTML.append(labClass(classes));
}
else //These are normal classes without lab components
{
returnAsHTML.append(openClass(classes));
}
}
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(returnAsHTML.toString());
}
My question is this, how would I begin to send the data the user has selected on the JSP page, and then sort through the ArrayList to find it? I know I can straight up inject java code into the JSP page using <% //code %>, but due to project requirements I cannot have scripting in the body of the page itself, its all linked externally.
For instance, if a user has checked "Springfield" under Location, and say "Summer" under semester, it should produce a table of all the classes in Springfield during summer. I just don't know how/where to start to learn how to send those parameters to search by in the servlet.