Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet NullPointer Exception

Have Programming Question? Ask it here!
 
 
 


Jagadeesh
NullPointer Exception
3 Answer(s)      6 years ago
Posted in : JSP-Servlet



Advertisement
View Answers

September 22, 2008 at 6:14 PM


hi jagdeesh,
you are printing the value of

int dno=(Integer)session.getAttribute("deptno");

out.println(deno);

is it printing properly may be null value coming from session check out that

thanks

Rajkumar


September 22, 2008 at 6:18 PM


And second thing Mr. Jagdeesh

<input type="text" name="mailid" size="20" tabindex="6" maxlength="40" title="Contact mail id" value="<%rs.getString(8);%>">

instead of this try to use expressions for text box value;

and get value write clearly for ex.

<input type="text" name="mailid" size="20" tabindex="6" maxlength="40" title="Contact mail id" value="<%=rs.getString("TableColum")%>">

thanks

rajkumar


September 22, 2008 at 6:28 PM


Hi friend,


I think, problem in your database connection code. So implement this code.


<%@ page language="java" import="java.sql.*" %>

<%
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar" ;
String password="amar123";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
try{
Statement st = con.createStatement();
String empname=request.getParameter("coursename");
String position=request.getParameter("couresefee");
String facultyname = request.getParameter("facultyname");

int val = st.executeUpdate("insert student values(id,'"+empname+"','"+position+"','"+facultyname+"')");

con.close();

out.println("successfully insert data into database!");
out.println("<br/>");
out.println("<a href=DynamicdisplaydataAction.jsp>Retrive Data from database</a>");

}
catch (SQLException ex){
System.out.println("SQL statement is not executed!");
}
}
catch (Exception e){
e.printStackTrace();
}

%>

-----------------------------------------

Thanks

Amardeep


Related Tutorials/Questions & Answers:
Nullpointer Exception - JSP-Servlet
Nullpointer Exception  Hi friends, the given below is my output of the servlet program? how can i solve this exception ? HTTP Status 500... Exception report message description The server encountered
Hibernate nullpointer exception - Hibernate
Hibernate nullpointer exception  Hi, I am using eclipse IDE.I copied hibernate example from roseindia.net. I am using MYSQL as my database. 1.In eclipse I hava created new javaproject. 2.I hava copied Contact.java. and I
Advertisements
NullPointer Exception - JSP-Servlet
NullPointer Exception  It is in jsp - mysql database program. In this pro. it enters into the statement before try statement. It does not enter into the try statement. I found this by checking out.println("test"); statement
how to solve the nullPointer Exception in main - Java Beginners
how to solve the nullPointer Exception in main  New to Java ,pls help me how fix Null pointer Exception in main: two files , split .java another...: Exception in thread "main" java.lang.NullPointerException
exception
exception  example for numberformat exception   Hi Friend, Try the following code: class NumberFormatExceptionEx{ public static void...); } catch(Exception e){ System.out.println(e
exception
defined checked exception ââ?¬Å?InvalidCharcterFoundExceptionââ?¬Â? and creater a block of codes that will handle the exception
Exception
Exception  public class FooException extends Exception { public..."); } public void calculate() throws FooException, Exception { try { int.... ex.printStackTrace(); System.exit(1); } catch(Exception ex
Exception
Exception   I was creating a table dynamically but it shows exception i.e shown down Suplier created0 Suplier created0 Suplier created0 Product created0 Product created0 Product created0 Product created0 could not fetch initial
exception
exception  Identify the reason for SQLException exception, which is encountered when the developer tries to run the following code snippet to insert..."); ps.executeUpdate(); } catch(Exception e
Exception handling
Exception handling  how to resolve file not found error exception
exception handling
exception handling   Give the exception hierarchy of Java.   Please visit the following links: http://www.roseindia.net/java/java-exception/exception-java.shtml http://www.roseindia.net/java/exceptions/exception
java exception
java exception   define an exception called no match exception tat z... { public static void main(String[] args) throws Exception { String z="Hello"; if(!z.equals("India")){ throw new Exception
Exception Handling
Exception Handling  create an exception class, which thros an exception if operand is non-numeric in claculating modules. ( Use command line arguments
Java exception
Java exception  What happens if an exception is not caught
Java exception
Java exception  Can an exception be rethrown
custom exception
custom exception  What is user defined exception
Java Exception
Java Exception  Which is superclass of Exception
Exception handling
Exception handling  exception are occur at run time but when we connect to the database errors will come at compile time why
Java exception
Java exception  What is the difference between Checked and Unchecked exception
Java exception
Java exception  What is the difference between exception and error
Getting Exception
Getting Exception  How to get exception from commented code in java
unchecked exception
unchecked exception  What happens if the service method throws an unchecked Exception
custom exception
custom exception  Explain the process of creating custom exception and handling it.   Please visit the following link: Making custom exception
Exception in PDFBOX
Exception in PDFBOX  "OperatorProcessor class org.pdfbox.util.operator.pagedrawer.StrokePath could not be instantiated" Not understanding about the exception.Kindly help me out to find why this exception is occuring
exception in servlet
exception in servlet  If a servlet is not properly initialized, what exception may be thrown?   During initialization or service of a request, the servlet instance can throw an UnavailableException
Exception Handling
Exception Handling  wrtie a java program to enable the user to handle any change of divide by zero exception.   Please visit the following link: http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml
exception handling
exception handling  What is an exception and what are the advantages of exception handling mechanism.   Java Exception Exception are the runtime errors. Advantages: 1)Exception provides the means to separate
Exception - Struts
Exception - java.lang.reflect.InvocationTargetException   java.lang.reflect.InvocationTargetException i am getting the foregoing error ...can anyone...: java.lang.reflect.InvocationTargetException: This is a checked exception that extends Exception Class thrown
exception Handling
exception Handling  write a program in Java to display the names and roll numbrs of students. Initialize respective array variables for 10 students. Handle ArrayIndexOutOfBoundsException, so that any such problem doesn't cause
exception handling
exception handling  a program to accept only three integer values as command line arguments. Print the values entered by the user. Handle ArrayIndexOutOfBoundsException and NumberFormatException by providing the applied messages
exception - Struts
exception  Hi, While try to upload the example given by you in struts I am getting the exception javax.servlet.jsp.JspException: Cannot...: Exception in JSP: /FileUpload.jsp:10 7: 8: 9: 10: 11: 12: 13
Creating Exception
Creating Exception  class Myexception extends Exception{ private int... exception(Myexception), but its showing invalid method declaration; return type...   Hi, Read at Java Exception examples. Thanks
Exception in Thread
Exception in Thread    i am developing a rmi application in eclipse... client and generate connection with server i have following exception : Blockquote Exception in thread "RMI TCP Connection(idle
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
exception in java
exception in java  StringIndexOutOfBounds Exception in flames program   Hi Friend, We have providing you a program. Try it: import java.util.*; public class FlamesProgram{ static String name1 = ""; static
exception - MobileApplications
"); } // System.out.println("hai"); catch (Exception e
exception - Spring
exception  org.springframework.dao.DataAccessResourceFailureException: Cannot open connection; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open connection Caused
Unhandled Exception
Unhandled Exception       Unhandled Exception are the exception  that are thrown  during the execution of program. These exception are never caught during
exception in java - Java Beginners
exception in java  exception in java
Java exception handling
Java exception handling  what are the constraints imposed by overriding on exception handling
Exception in Struts - Struts
Exception in Struts  1.How we handle exception in struts? 2.How we write our custome exception in struts? 3.When the struts-config.xml will be loaded
null pointer exception in java
null pointer exception in java  What is null pointer exception in Java and when it occurs? Show it with an example.Thanks!   Java Null Pointer Exception
Java Exception - Exception Handling in Java
Java Exception - Exception Handling in Java       Exception, that means exceptional errors... and catch the errors using catch() block. Exception turns the direction of normal
 

 

 

DMCA.com