|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Tomcat, Jsp and Java Files
I am new to java and trying to implement a application on to Tomcat 5.5.9. Recievings the following errors.
java.lang.NullPointerException training.rules.TrainingSession.getJobTitleIds(Trai ningSession.java:1062) org.apache.jsp.searchJob_jsp._jspService(org.apach e.jsp.searchJob_jsp:339) org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet .java:802) org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet .java:802) org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:362) Here snippet of where the code error: public MultiValue getJobTitleIds() { Hashtable validityTables = SessionManager.get(getApplication()).getValidityTa bles(); KeyedList validJobTitles = ((KeyedList )validityTables.get("Job_Table")); if (!validJobTitles.isValid()) { try { getValidJobTitles(); } catch (IOException e) {} // We did the best we could to repopulate the cache. } // end of if return(jobTitleIds); } // end of method 'getJobTitleIds' |
|
#2
|
||||
|
||||
|
First of all : any NullpointerException means that you're trying to access an object that doesn't exist (yet).
To be honest : I'm just a java amateur and I must admit I haven't worked with KeyedList. So, I can't say where your error is. But then, the error message is giving you a clue : it mentions searchJob_jsp:339. You must know that every JSP is translated first into a servlet. So, I suppose you have a searchJob.jsp. This will be translated in a searchJob_jsp.java, then it will be compiled into a searchJob_jsp.class file. So, to know where it went wrong, you should take a look at the java file which corresponds to your JSP. Where can you find it ? Well, in my case I have a web application which is located at C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\gco. The translated JSP's can be found at C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\gco. So, look up the java file searchJob_jsp.java and look at line 339. This will give you a clue about which object hasn't been created yet. |
|
#3
|
||||
|
||||
|
Just to help you out a bit. If you're new to java and JSP's, you should know this.
You can write java web applications with only java server pages. And in each JSP you can connect to the database and look up the necessary data and show it to the user. Imagine you have a web app containg about 15 JSP's. The day you're changing your database, you will have to change 15 JSP's. Or you can follow the MVC or Model-View-Controller design pattern. That way, you're dividing your application into the following components : - model : these are the javabeans which contain properties and getters and setters. These javabeans correspond to the concepts the user of the web app knows. For instance, a web app made to sell products, will surely contain the javabeans Customer, Product, Order, Invoice, Payment. - view : this is the collection of JSP's. The only thing a JSP has to do is to show the information contained inside the javabeans. Who makes those javabeans ? Well, that's the third part. - controller : this is the heart of the web application. The controller is the servlet(s) who accept a request and decide which response should be given. If you're looking for a free book, go to www.coreservlets.com. You can download the first edition of this classic book of Marty Hall for free. Another great book is the "Apache Tomcat Bible". The title is a bit misleading, since it explains a lot more : how to download java, MySQL, Tomcat, Eclipse. ANd it gives an overview of the MVC and how to implement it. A must have ! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Tomcat, Jsp and Java Files |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|