| Author |
Display information
|
Deepak Chawla
Ranch Hand
Joined: Nov 19, 2003
Posts: 50
|
|
I have a form when user hits submit, a servlet is called to store information in database, but that servlet calls a java class because i am using that class for all my database queries, so in that class i am insering but i don't know how to display the information back to user that information is added sucessfully. plz help
|
 |
maneesh subherwal
Ranch Hand
Joined: Aug 26, 2002
Posts: 42
|
|
your class should return something back to the servlet indicating success or failure. Based on that flag, the servlet could either forward to an appropriate jsp or use the response writer to output required html. hope this helps Maneesh
|
Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
|
 |
Deepak Chawla
Ranch Hand
Joined: Nov 19, 2003
Posts: 50
|
|
This is my servlet: package servlet; import DBAccess.*; import java.io.*; import java.util.*; import java.sql.*; import javax.sql.*; import javax.servlet.*; import javax.naming.*; import javax.servlet.http.*; public class insertProject extends HttpServlet { public void doPost (HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException { String ProjectName = request.getParameter("pname"); String Description = request.getParameter("description"); String OrgName = request.getParameter("orgname"); String ArchitectId = request.getParameter("architectid"); String SystemName = request.getParameter("systemname"); String BusinessUnit = request.getParameter("businessunit"); ProjectDatabase pd=new ProjectDatabase(); pd.createProject(ProjectName,Description,OrgName,ArchitectId,SystemName,BusinessUnit); } /* i can display the information here*/ } this is the method in my Projectdatabase class: /* shall i declare a boolean variable and after my insert query intilize it as true and then return that to the servlet, then how i will grab the value in my servlet*/ plz help public void createProject( String ProjectName,String Description,String OrgName,String ArchitectId,String SystemName,String BusinessUnit ) { try { Context context = new InitialContext(); DataSource ds = (DataSource) context.lookup( "itarchutil-datasource" ); Connection con = ds.getConnection(); /* i got my insert query here */ stmt.close(); con.close(); } catch (Exception e) { System.out.println("Error:" + e); } }
|
 |
Tom Blough
Ranch Hand
Joined: Jul 31, 2003
Posts: 263
|
|
[ December 02, 2003: Message edited by: Tom Blough ]
|
Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
|
 |
 |
|
|
subject: Display information
|
|
|