Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML


 

Java Tutorials

Core Java
JSP
Servlet
JDBC
Hibernate
Struts 1
Struts 2
JSF
Spring
J2EE
J2ME
Web Services
Ajax
Dojo
MySQL
Latest Comments
Good one ...But Mi
ATA-S2 Ip configur
Nice article
Create Exe File
i want struts2 IDE
  All Comments...
 

 

 
Struts Tutorials
*Stuts TOC
*Apache Struts Introduction
* Struts Controller
* Struts Action Class
* Struts ActionFrom Class
* Using Struts HTML Tags
*Struts Validator Framework    
*Client Side Address Validation    
*Struts Tiles
*tiles-defs.xml
*Struts DynaActionForm
*Struts File Upload
*Struts DataSource
*AGGREGATING ACTIONS
*Internationalization
Struts Resources
*Struts Books
*Struts Articles
*Struts Frameworks
*Struts IDE
*Struts Alternative
*Struts Links
*Struts Presentations
*Struts Projects
*Struts Software
*Struts Reference
*Struts Resources
*Other Struts Tutorial
Visit Forum! Post Questions!
Jobs At RoseIndia.net!

Have tutorials?
Add your tutorial to our Java Resource and get tons of hits.

We offer free hosting for your tutorials. and exposure for thousands of readers. drop a mail
roseindia_net@yahoo.com
 
   

 
Join For Newsletter

Powered by groups.yahoo.com
Visit Group! Post Questions!

Jsp Accessingdatabase FromJSP

User Comments
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl
  Blink   Furl   Simpy   Y! MyWeb 

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

43 comments so far (post your own) View All Comments Latest 10 Comments:

org.apache.jasper.JasperException: An exception occurred processing JSP page /hello/BookEntryForm.jsp at line 30

27: String bookname=request.getParameter("book_name");
28: String author=request.getParameter("author");
29:
30: stmt.executeUpdate("insert into books_details(book_name,author) values('"+bookname+"','"+author+"')");
31:
32:
33: rst=stmt.executeQuery("select * from books_details");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.hello.BookEntryForm_jsp._jspService(BookEntryForm_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Posted by Petẻ on Tuesday, 10.14.08 @ 12:45pm | #81076

org.apache.jasper.JasperException: An exception occurred processing JSP page /hello/BookEntryForm.jsp at line 30

27: String bookname=request.getParameter("book_name");
28: String author=request.getParameter("author");
29:
30: stmt.executeUpdate("insert into books_details(book_name,author) values('"+bookname+"','"+author+"')");
31:
32:
33: rst=stmt.executeQuery("select * from books_details");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.lang.NullPointerException
org.apache.jsp.hello.BookEntryForm_jsp._jspService(BookEntryForm_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

Posted by Lan on Tuesday, 10.14.08 @ 12:38pm | #81075

How i can deploy in webhosting my jsp with a database??(without it i create war file...)

Posted by Alex Sunyava on Monday, 10.13.08 @ 17:08pm | #81046

Hi, can I retrieve values in many database(database1 and database2) in a single jsp? how is the statement i should make?
how if i use microsoft access instead of mySQL? thank u!

Posted by susi on Wednesday, 05.21.08 @ 08:16am | #60563

Hi,This is Pradeep,
I want to know how to write custom tags in jsp,pls give me a simple example with explanation

Posted by M.V.V.Pradeep on Thursday, 05.8.08 @ 16:35pm | #58911

i want edit&delete program in jsp using jdeveloper.
please sebd the code.

Posted by ashok on Friday, 05.2.08 @ 09:40am | #58352

I have made one jsp page which is having 11 buttons. if i will click any of button it should fetch the data from oracle database corresponding to that table. what is the code which i can use for this. or if u can give any link or code for this.

Posted by Ankur on Tuesday, 03.25.08 @ 11:51am | #54233

hi please send the full codings it helps to create a new document.

Posted by subhashini on Wednesday, 03.5.08 @ 11:24am | #51393

hi,
Please send me full code.......
i will try to help for ur problem..


Regards,
G.Krishna

Posted by krishna on Thursday, 02.28.08 @ 17:23pm | #50457

plz help me.......
exception

org.apache.jasper.JasperException: Exception in JSP: /in.jsp:22

19: if(request.getParameter("action") != null){
20: String bookname=request.getParameter("bookname");
21: String author=request.getParameter("author");
22: stmt.executeUpdate("insert into books_details(book_name,author) values('"+bookname+"','"+author+"')");
23: rst=stmt.executeQuery("select * from books_details");
24: %>
25: <html>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NullPointerException
org.apache.jsp.in_jsp._jspService(in_jsp.java:65)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

Posted by sreekanth on Thursday, 02.28.08 @ 11:41am | #50383

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /in.jsp
Generated servlet error:
String literal is not properly closed by a double-quote


org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

Posted by sreekanth on Wednesday, 02.27.08 @ 11:38am | #50280

Hi
This is Raghavendra
I have doubt how to extablish the connection between JAVA progam and Database i.e sql,
pls give me example also.

Posted by Raghavendra on Monday, 02.25.08 @ 14:57pm | #49943

Hi,

I think your error is related to the incorrect installation of the mysql.

Please reinstall MySQL on fresh machine and then try.

Hopefully on new machine your problem will be solved.

Thanks

Posted by Deepak Kumar on Thursday, 02.21.08 @ 17:06pm | #49316

i cant create table in mysql because of this error message"access violation at address 005cfc42 in module "heidisql.exe" read the address 00000054 " kindly help me to fix this problem..coz i need it badly..Thanks!!!

Posted by marky on Thursday, 02.21.08 @ 16:36pm | #49312

what is the ment by org.gjt.mm in driver conncetion
String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();
please give me the explanation

Posted by Riyas on Saturday, 02.9.08 @ 13:30pm | #47666

hi,
i m feeling problem in fetching data from arraylist to jsp page as it my jdk version is 1.4 i cannot use the higher version generics please help me
my source code is

Action class

try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,"root","root");
try{
Statement st = (Statement) con.createStatement();
String sqll ="select * from "+hitesh+" order by "+arrangeby;
ResultSet rs = (ResultSet) st.executeQuery(sqll);
ArrayList ls=new ArrayList();
while (rs.next()){
Leave leave=new Leave();

ls.add(rs.getString(1));
ls.add(rs.getString(2));
ls.add(rs.getString(3));
ls.add(rs.getString(4));
ls.add(rs.getString(5));
ls.add(rs.getString(6));
ls.add(rs.getString(7));
ls.add(rs.getString(8));
ls.add(rs.getString(9));
ls.add(rs.getString(10));
ls.add(rs.getString(11));
ls.add(rs.getString(12));
ls.add(rs.getString(13));
ls.add(rs.getString(14));
ls.add(rs.getString(15));
ls.add(rs.getString(16));
ls.add(rs.getString(17));
ls.add(rs.getString(18));
ls.add(rs.getString(19));
ls.add(rs.getString(20));
ls.add(rs.getString(21));
ls.add(rs.getString(22));
ls.add(rs.getString(23));
ls.add(rs.getString(24));
ls.add(rs.getString(25));
request.setAttribute("list",ls);


}





System.out.println("1 row affected");
}
catch (SQLException s){
System.out.println("SQL statement is not executed!");
System.out.println("select * from "+hitesh+" order by "+arrangeby);
}
}
catch (Exception e){
e.printStackTrace();
}


jsp page
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<%@ page language="java" import="java.sql.*" %>

<html>
<head>
<title> VIEW</title>
</head>

<body>
<html:form action="/uview">
<table>
<tr><td><html:link forward="hom">HOME</html:link></td>
<td><html:link forward="log">LOGOUT</html:link></td></tr>
<tr><td><bean:message key= "viewby"></bean:message></td>
<td><html:select property="selectview">
<option value="Policy_holders_fname">Name
<option value="plan">Plan
<option value="term">Terms
<option value=" date_of_last_premium_paid"> Premium Pain on
<option value="sum_asshured">Sum Assured
<option value="policy_no"> Policy No
<option value=" mode_of_payment">Mode
<option value=" date_of_birth">Date of Birth
<option value="branch_code">Branch Code </html:select> </td>
<td><html:submit value="VIEW"></html:submit></td></tr>
<table cellspacing="5" cellpadding="5" border="1"> <tr>
<td>Policy Holder First Name</td>
<td>Middle Name</td>
<td>Last Name</td>
<td>Sex</td>
<td>Address</td>
<td>Date of Birth</td>
<td>Email Id</td>
<td>Phone NO.</td>
<td>Mobile No.</td>
<td>Policy No.</td>
<td>Branch Code</td>
<td>Date of Commencement</td>
<td>Sum Asshured</td>
<td>Plan</td>
<td>Term</td>
<td>Mode of Payment</td>
<td>Premium Amount</td>
<td>Premium Due Date</td>
<td>Date of Last Premium Paid</td>

<!-- to do , here is the code to be writen i have a code which gives me jasper exception
<% ArrayList ls=(ArrayList)request.getAttribute("list");

Iterator it=ls.iterator();

int i=1;

while(it.hasNext())

{

out.print("<td>"+it.next()+"</td>");

if(i%5==0)

out.print("</tr><tr>");

i++;

}
%>

-->

</html:form>


</table>

</table>

</body>
</html>

please help me

Posted by hitesh on Monday, 01.21.08 @ 21:31pm | #45799

while view the employeeno column not found in jsp

Posted by T.vivek on Tuesday, 12.18.07 @ 18:36pm | #42839

good for new programers
self study materials
i want more...

Posted by sangamesh on Tuesday, 11.20.07 @ 17:12pm | #38048

I am getting output as
System connected null After Executing the Querycom.mysql.jdbc.ResultSet@cc70f8
Please check the program
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%! Connection con=null; %>
<%! Statement st= null; %>
<%! ResultSet rs= null; %>
<%! boolean found =false; %>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
try
{
con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","mysql");
out.println("System connected\n");
st = con.createStatement();
String s1=request.getParameter("uname");
out.println(s1);
rs=st.executeQuery("select * from user where name='"+s1+"'");
session.setAttribute("name",s1);
String s2=request.getParameter("pswd");
out.println("After Executing the Query" + rs);
while(rs.next())
{
out.println(rs.getString(s1));
String rs1=rs.getString(1);
//session.setAttribute("user");
String rs2=rs.getString("pswd");
if(s2.equalsIgnoreCase(rs2))
{
int id=rs.getInt("userid");
out.println("After Executing the Query" );
int userid=rs.getInt("userid");
out.println(userid);
}
}
}
catch(Exception e)
{
System.out.println("validation failure"+e);
}
finally
{
st.close();
rs.close();
con.close();
}
%>

Posted by neelima on Thursday, 11.15.07 @ 16:54pm | #37492

hi i am getting jasper error while connecting jsp program to mysql... i tried with program given in site
http://www.roseindia.net/jsp/Accessingdatabase-fromJSP.shtml

but its not connecting & giving this error so please reply how to remove this error

Posted by saurabh on Monday, 10.15.07 @ 12:07pm | #33845

How i can connect to database

Posted by Om on Sunday, 09.30.07 @ 19:43pm | #30510

There are many websites with Jsp contents, but most of these contents are useful for advanced user and some other contents are not well eplained. If someone is looking for a well organised tutorial i can choose for him or her this one.
thanx for your tutorials

Posted by Ruthra on Tuesday, 09.25.07 @ 17:34pm | #29325

Hi..,
I dont have idea about connecting through MYSQL server. I do have Oracle 9i. Can you get me how to access DB from JSP in Oracle

Posted by praveena on Wednesday, 08.29.07 @ 12:04pm | #24406

hi im new to this

where to keep mysql connector jar files,
whether i have to put mysql connector jar files in
C:\apache-tomcat-6.0.13\lib
or
it supposed to be in
webinff\lib
im getting error :CLASS NOT FOUND EXCEPTION

your help more appriciated

Posted by ramesh on Thursday, 08.23.07 @ 19:42pm | #23992

Hello ,
i am new to JSP.I am able to pass the elements from one form to another form.But i am unable to store the data into the database.Here we are using MS-Access .Can u send me the code for the database connection in MS-Access

Posted by ramya on Wednesday, 08.22.07 @ 11:45am | #23888

i try to compiled all of the codes in jsp files is not working with mysql

can help pls.

Posted by jay on Friday, 08.3.07 @ 14:53pm | #22572

ur examples are very useful for me.i am a beginner.i can easily unterstood using ur very well explanation

Posted by jayanthy on Friday, 07.27.07 @ 11:37am | #22035

There are many websites with Jsp contents, but most of these contents are useful for advanced user and some other contents are not well eplained. If someone is looking for a well organised tutorial i can choose for him or her this one.
thanx for your tutorials

Posted by Jean-Paul on Wednesday, 07.18.07 @ 08:34am | #21479

It was a great help for me as a starter

Posted by jhilmil on Wednesday, 07.11.07 @ 12:46pm | #21070

nice example..very simple and very explanatory...

Posted by srishti on Tuesday, 07.3.07 @ 16:26pm | #20659

can any one give me the code regarding user authentication using flat files in jsp/ html

Posted by anji on Monday, 06.25.07 @ 12:45pm | #20140

This is a good one for a beginer.Thank you
very much.

Posted by user on Wednesday, 05.23.07 @ 04:28am | #17049

Hi,

We are using the hidden field
<input="hidden" value="list" name="action"> in

to find determine the form submit event.

If form is submitted, we are determining it using following code:

if(request.getParameter("action") != null){
.......

stmt.executeUpdate("insert into books_details(book_name,
author) values('"+bookname+"','"+author+"')");
.....
}
%>

and data is added to the database.
Thanks

Posted by Deepak on Sunday, 05.20.07 @ 09:54am | #16810

Respected sir,
Could u plz exaplain the line
<input="hidden" value="list" name="action"> in this code....
And y do we actually make any parameter hidden....

Posted by pradeep on Saturday, 05.19.07 @ 19:50pm | #16569

1.can u plz tell me what is use of this portion: <input type="hidden" value="list" name="action">

2.I followed all the procedures given by you in this tutorial.I also created table with 3 fields in database.I got the book entry form.But when I filled the field and click submit I got some error messages that is shown below. please help.The following errors I got...

org.apache.jasper.JasperException: An exception occurred processing JSP page /resume.jsp at line 20

17: String author=request.getParameter("author");
18: String str = "insert into books_details(book_name, author) values('"
19: + bookname + "','" + author + "')";
20: s.executeUpdate(str);
21: rs=s.executeQuery("select * from books_details");
22: %>
23:

Posted by dhivya on Friday, 05.18.07 @ 12:59pm | #16363

hi sanjeev

before executing this code u have to create a table with specified table name(books_details) with two fields.(book_name and author).

thanks

Posted by dhinesh on Monday, 05.14.07 @ 11:36am | #15828

hi
this is very useful to me>

thanks.

Posted by dhinesh on Monday, 05.14.07 @ 11:10am | #15825

Sir please help me in solving my problem . I tested your tutorial and got the book entry form.But when I filled the field and click submit I got some error messages that is shown below.Iam only a beginner.so please help.The following errors I got...


Errors:

org.apache.jasper.JasperException: Exception in JSP: /BookEntryForm.jsp:30

27: String bookname=request.getParameter("bookname");
28: String author=request.getParameter("author");
29:
30: stmt.executeUpdate("insert into books_details(book_name,author) values('"+bookname+"','"+author+"')");
31:
32:
33: rst=stmt.executeQuery("select * from books_details");

Posted by sajeev ramakrishnan on Sunday, 05.6.07 @ 10:13am | #15338

org.apache.jasper.JasperException: Exception in JSP: /index.jsp:8


5: %>
6: <%
7:
8: Class.forName("com.mysql.jdbc.Driver").newInstance();
9:
10:
11: Connection con=null;

Please help to sloved it

Posted by five on Wednesday, 05.2.07 @ 21:30pm | #15181

i like this very much.thanks for providing this tutorial.

Posted by bilumon on Thursday, 04.26.07 @ 10:55am | #14949

can u plz tell me what is use of this portion: <input type="hidden" value="list" name="action">

Posted by ALOK RANJAN UDGATA on Thursday, 04.12.07 @ 13:54pm | #13948

Can you please send me the connection to a sql database

Posted by Benny on Tuesday, 04.3.07 @ 15:40pm | #13264

Hi,
Thanks, This is a good one for a beginer

Posted by User on Tuesday, 03.27.07 @ 12:14pm | #12773

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Back to Tutorial

 

  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.