Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display information

 
Deepak Chawla
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Deepak Chawla
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[ December 02, 2003: Message edited by: Tom Blough ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic