Durga Sanju

Greenhorn
+ Follow
since Jun 03, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Durga Sanju

hi,

below is the jsp code....

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.sql.*"%>
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>
<%@page import="org.hibernate.Transaction"%>
<%@page import="org.hibernate.Session"%>
<%@page import="org.hibernate.SessionFactory"%>
<%@page import="org.hibernate.HibernateException"%>
<%@page import="org.hibernate.cfg.*" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Session sess=null;
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
sess=sessionFactory.openSession();
System.out.println("Inserting Record");
Writer wr = new Writer();
wr.setName("Das");
ArrayList list = new ArrayList();
list.add(new Story("Story Name 1"));
list.add(new Story("Story Name 2"));
wr.setStories(list);
Transaction transaction = null;
try {
transaction = sess.beginTransaction();
sess.save(wr);
transaction.commit();
} catch (Exception e) {
if (transaction != null) {
transaction.rollback();
throw e;
}
} finally {
sess.close();
}

%>
</body>
</html>

I found the error...

I included that page encoding directive twice in my JSP..

.

I got the following error in my JSP now...



type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

An error occurred at line: 11 in the generated java file
Only a type can be imported. org.hibernate.Transaction resolves to a package

An error occurred at line: 12 in the generated java file
Only a type can be imported. org.hibernate.Session resolves to a package

An error occurred at line: 13 in the generated java file
Only a type can be imported. org.hibernate.SessionFactory resolves to a package

An error occurred at line: 14 in the generated java file
Only a type can be imported. org.hibernate.HibernateException resolves to a package

An error occurred at line: 22 in the jsp file: /Save.jsp
Session cannot be resolved to a type
19: </head>
20: <body>
21: <%
22: Session sess=null;
23: SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
24: sess=sessionFactory.openSession();
25: System.out.println("Inserting Record");


An error occurred at line: 23 in the jsp file: /Save.jsp
SessionFactory cannot be resolved to a type
20: <body>
21: <%
22: Session sess=null;
23: SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
24: sess=sessionFactory.openSession();
25: System.out.println("Inserting Record");
26: Writer wr = new Writer();


An error occurred at line: 23 in the jsp file: /Save.jsp
Configuration cannot be resolved to a type
20: <body>
21: <%
22: Session sess=null;
23: SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
24: sess=sessionFactory.openSession();
25: System.out.println("Inserting Record");
26: Writer wr = new Writer();


An error occurred at line: 29 in the jsp file: /Save.jsp
The constructor Story(String) is undefined
26: Writer wr = new Writer();
27: wr.setName("Das");
28: ArrayList list = new ArrayList();
29: list.add(new Story("Story Name 1"));
30: list.add(new Story("Story Name 2"));
31: wr.setStories(list);
32: Transaction transaction = null;


An error occurred at line: 30 in the jsp file: /Save.jsp
The constructor Story(String) is undefined
27: wr.setName("Das");
28: ArrayList list = new ArrayList();
29: list.add(new Story("Story Name 1"));
30: list.add(new Story("Story Name 2"));
31: wr.setStories(list);
32: Transaction transaction = null;
33: try {


An error occurred at line: 32 in the jsp file: /Save.jsp
Transaction cannot be resolved to a type
29: list.add(new Story("Story Name 1"));
30: list.add(new Story("Story Name 2"));
31: wr.setStories(list);
32: Transaction transaction = null;
33: try {
34: transaction = sess.beginTransaction();
35: sess.save(wr);


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)



i didnt change any code after that
hi,

I got the following exception

HTTP Status 500 -

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

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /Save.jsp(3,5) Page directive must not have multiple occurrences of pageencoding
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:194)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:608)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
org.apache.jasper.compiler.Validator.validateDirectives(Validator.java:1696)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:167)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)




i have included code of all the required files. Please tell wat's wrong with the code


//hibernate.cfg.xml


//Story.hbm.xml



//Writer.hbm.xml



//save.jsp


//Writer POJO class


//Story POJO Class


Hi Shannon,

I'm very new to hibernate. Can You please help me with an example for that.


Thanks,
-Durga
.save() query inserts every time only new records when i relaunch my application resulting in deletion of existing rows.

Thanks for explanation on this
Wat i meant was when i close my application and launch it again, the insert query inserts only new set of records deleting the existing records
Hi,

I need to know how can we insert new records into our table using hibernate. Actually when using hibernate query to insert record, it will delete the existing records and insert the new records. But i want to insert the new records along with the existing records.

Any information on this will be really helpful for me.



ok..... thanks
Hi,

What is the acronym for

dojo

.?
Please send the code for connecting android with servlet. Yours is the first and foremost that you have successfully connected, because i have googled almost all the sites but nothing worked.

It will be very very helpful if you send me the code for both client and server.

Thanks in advance.
12 years ago