Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.NumberFormatException: null

807580Apr 26 2010 — edited Apr 28 2010
Hi
I need your help again
i was working on a JSP and servlet project on apache tomcat
i got the following error when i start apache server
Apr 26, 2010 6:23:33 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet co_sem_data threw exception
java.lang.NullPointerException
        at myPackage.co_sem_data.processRequest(co_sem_data.java:31)
        at myPackage.co_sem_data.doGet(co_sem_data.java:111)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
        at java.lang.Thread.run(Thread.java:619)
Apr 26, 2010 6:35:23 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 328 in the jsp file: /co_sem.jsp
The method print(char[]) is ambiguous for the type JspWriter
325: 
326:                                 </table>
327:                                 <%} catch(Exception e){e.getMessage();}%>
328:                                 <div align="center"><input   type="button" value="jjjj" name="co_sem_data.jsp?id=<%=null%>" onclick = "popUp(this.name);">
329:                         </div></div>
330: 
331:                 </div>
i don't know why ?
i tried to find the bug but i didn't figure it out
here is the servlet code
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package myPackage;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

    protected void processRequest(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
        res.setContentType("text/html;charset=UTF-8");
        PrintWriter out = res.getWriter();
        try {

            HttpSession userSession = req.getSession(false);
int id = Integer.parseInt(req.getParameter("id").toString());
 String info[] = new String [28];
         try{info=DBOP.get_sem_basic_info(id);
         
         }catch (SQLException E) {
            out.println("SQLException: " + E.getMessage());
            out.println("SQLState:     " + E.getSQLState());
            out.println("VendorError:  " + E.getErrorCode());



        }




                    userSession.putValue("sinfo[1]", info[1]);
                   
                    userSession.putValue("sinfo[26]",info[26]);
                    userSession.putValue("semid", id);
                    System.out.println(id);





            RequestDispatcher redirect = getServletContext().getRequestDispatcher("/co_sem_data.jsp");
            if (redirect != null) {redirect.forward(req, res);}
           
        } finally { 
            out.close();
        }
    } 
}
and here is the JSP code
		
			<!-- 
	
	MAIN CONTENT AREA
	
	-->
			<div id="content">
				<div id="breadcrumbs">
					<a href="co_welcome.jsp">&#1575;&#1604;&#1589;&#1601;&#1581;&#1577; &#1575;&#1604;&#1585;&#1574;&#1610;&#1587;&#1610;&#1607;</a> /&#1573;&#1583;&#1575;&#1585;&#1577; &#1575;&#1604;&#1576;&#1585;&#1606;&#1575;&#1605;&#1580;/
					<a href="co_sem.jsp">&#1576;&#1610;&#1575;&#1606;&#1575;&#1578; &#1578;&#1610;&#1585;&#1605;</a>
					<br>
				</div>
				<a name="maincontent" id="maincontent"></a>
				<h1>&#1576;&#1610;&#1575;&#1606;&#1575;&#1578; &#1575;&#1604;&#1578;&#1610;&#1585;&#1605;</h1>
				<p></p>
                                <%String id ="";%>
                                <%
     try {
         PreparedStatement Stmt = null;
         DBOP.load_db_driver();
         Connection Conn = DBOP.connectToDb();
         Stmt = Conn.prepareStatement("SELECT `Sem-record-id`,`Sem-year`,`Sem-term-code`  FROM semesterbasicinfo");
         
           Stmt.execute();
         ResultSet RS = Stmt.getResultSet();
         RS.last();
         int rows=RS.getRow();
         RS.beforeFirst();
         %>
				<table border="1" width="100%" style="border-collapse: collapse">
					<tr>
						<td align="center">
							<font color="#FF0000"><b>y</b> </font>
						</td>
						<td align="center">
							<font color="#FF0000"><b>t</b> </font>
						</td>
						<td align="center">
							<font color="#FF0000"><b>ag</b> </font>
						</td>
						<td align="center">
							<font color="#FF0000"><b>pro</b> </font>
						</td>
					</tr>

					<%while (RS.next()) {%>
                                        <%String term=RS.getString(3);term=DBOP.get_Term(term);%>
                                        <tr><%id =RS.getString(1);%>
						
						<td><%=RS.getString(2)%>
						</td>
                                                <td><%=term%>
						</td>
                                                <td> <a onclick = "popUp(this.name);" name="co_sem_data?id=<%=id%>">ag</a>                      <-------1------>
						</td>
						<td><a onclick = "popUp(this.name);" name="co_sem_detail?id=<%=id%>">pro</a>                      <-------2------->
						</td>

					</tr>
                                        <%}%>

				</table>
                                <%} catch(Exception e){e.getMessage();} %>
                                <div align="center"><input   type="button" value="add" name="co_sem_data.jsp?id=0" onclick = "popUp(this.name);">    <-----------3-------->
			</div></div>

		</div>
also i have another problem which is when i click on the button 3 as the first thing i do on the page it works fine, but when i click on link 1 or 2 then i click on the button it does not identify the id well.
can any one hlep
please
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 26 2010
Added on Apr 26 2010
5 comments
3,555 views