solve this pbm

solve this pbm

sir rows are also inserting i have checked in the database also the rows are not affected in the table .

The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we can execute the program

View Answers

January 21, 2011 at 4:38 PM

Hi Friend,

Follow these steps to create and execute a servlet:

Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet.

import java.io.*;
import java.sql.*;
import javax.servlet.*; 
import javax.servlet.http.*;

public class DataInsertion extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{

response.setContentType("text/html"); 
PrintWriter out = response.getWriter();
String url = "jdbc:mysql://localhost/test?user=root&password=root";
Connection conn; 
ResultSet rs; 
try{ 
    Class.forName("com.mysql.jdbc.Driver"); 
    conn = DriverManager.getConnection(url);
    Statement statement = conn.createStatement();
    String query = "insert into emp(EMP_NAME,SALARY) values('roseindia', 10000)";
    int i = statement.executeUpdate(query);
    if(i!=0){
        out.println("The record has been inserted<br>"); 
        } 
        else{
            out.println("Sorry! Failure");
            } 
            rs = statement.executeQuery("select * from emp"); 
            while(rs.next()){
                out.println(""+rs.getString("EMP_NAME") + " " + rs.getInt("SALARY") + "<br>"); 
                } 
                rs.close();
                statement.close();
                }
                catch (Exception e){
                    System.out.println(e); 
                    }
                    }
                    }

2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.

3)Create web.xml and classes folder inside the WEB_INF folder of web application folder assuming 'examples'.

4)Copy the servlet to the classes folder.

5)Edit the web.xml to include servlet?s name and url pattern.

   <servlet>
        <servlet-name>DataInsertion</servlet-name>
        <servlet-class>DataInsertion</servlet-class>
    </servlet>

   <servlet-mapping>
        <servlet-name>DataInsertion</servlet-name>
        <url-pattern>/DataInsertion</url-pattern>
    </servlet-mapping>

6)Compile your servlet.

7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.

8)Open the browser and type the following url:

http://localhost:8080/examples/HellWorld

Thanks









Related Tutorials/Questions & Answers:
solve this pbm
solve this pbm  sir rows are also inserting i have checked in the database also the rows are not affected in the table . The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we
solve this pbm
solve this pbm  its not working the code for databae access using servlets
Advertisements
ModuleNotFoundError: No module named 'pbm'
ModuleNotFoundError: No module named 'pbm'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pbm' How to remove the ModuleNotFoundError: No module named 'pbm' error
ModuleNotFoundError: No module named 'pbm'
ModuleNotFoundError: No module named 'pbm'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pbm' How to remove the ModuleNotFoundError: No module named 'pbm' error
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
solve this
solve this   Create a student class. The student object should have studentid, studentname, subject and marks as properties. Also generate the getter and setter methods. Create 5 objects of this class and populate values
how to solve
how to solve   log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly
Solve
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
solve this problem
solve this problem  I typed this program and compiled.The program is compiled but when i eneterd url in tomcat server. Its not giving error but only blank page is coming the text is not displaying and row is also inserted
ModuleNotFoundError: No module named 'solve'
ModuleNotFoundError: No module named 'solve'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'solve' How to remove the ModuleNotFoundError: No module named 'solve'
A Program To Solve In Java
A Program To Solve In Java  x!/x+(x+2)!/x+(x+4)!/x ... (x+n)!/x
help me to solve this question
help me to solve this question  Write a program that inputs a series of integers into an array. The numbers are in the range 0 to 100. Calculate and display : a) The Largest number b) The Smallest Number c)The sum of the numbers
How to solve the Hibernate Common Exceptions?
How to solve the Hibernate Common Exceptions?  How to solve the Hibernate Common Exceptions
please solve this program
please solve this program  Build a package EMPPACK that contains one stored function Validatesal() and two stored procedures Insertemp() and Getempdetails().The Insert_emp() procedure inserts a particular employee
please solve the programme
please solve the programme  Develop a java program to find the roots of a quadratic equation ax2+bx+c=0, with the following specification :- Class name :- Quad Data members float a,b,c,d, with a,b,c are the co-efficient
Solve Program - Java Beginners
Solve Program  Write a progaram in java to display all odd number from 1 to 100   hi use this code package rajanikant.code.sep_2008; public class EvenOdd { public static void main(String s
help me to solve this question...
help me to solve this question...  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s
help me to solve this problem..
help me to solve this problem..  Given below is a class definition for Book. Type and compile the class, and answer the following questions: class Book { String title; //bookâ??s title double price; //bookâ??s price
plz solve my query?
plz solve my query?  how to remove all the options from select control in html using java script?   JavaScript remove all items <html> <script language="javascript" > function removeAllItems(selectbox
Solve it - Java Beginners
Solve it  Hi Friends, Thanks for continue reply.. I have some query please solved...its urgent.. I have two table,emp,exam.both have e... is write here. no information display in the jsp file please solve it and let me
Solve this problem plzzz
Solve this problem plzzz  Prashant.jsp (this is my JSP file) <HTML> <HEAD> <TITLE>Login using jsp <BODY>... kindly help me and check all those files and solve my problem as soon as possible
ModuleNotFoundError: No module named 'magiceye_solve'
ModuleNotFoundError: No module named 'magiceye_solve'  Hi, My... named 'magiceye_solve' How to remove the ModuleNotFoundError: No module named 'magiceye_solve' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'flood-solve'
ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python... 'flood-solve' How to remove the ModuleNotFoundError: No module named 'flood-solve' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'flood-solve'
ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python... 'flood-solve' How to remove the ModuleNotFoundError: No module named 'flood-solve' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'solve-instrument'
ModuleNotFoundError: No module named 'solve-instrument'  Hi, My... named 'solve-instrument' How to remove the ModuleNotFoundError: No module named 'solve-instrument' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'sudoku-solve'
ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python... 'sudoku-solve' How to remove the ModuleNotFoundError: No module named 'sudoku-solve' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'sudoku-solve'
ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python... 'sudoku-solve' How to remove the ModuleNotFoundError: No module named 'sudoku-solve' error? Thanks   Hi, In your python
solve it - Java Beginners
solve it  Hi friend, I want to use switch case in jsp please let me know how to call page in jsp using include tag i want call this file using include tag please help me use switch statement in jsp
ArrayList question plz solve it
ArrayList question plz solve it  An arraylist object stores an Emp Object, where there is name,age,address of the employee is stored, And i want to access the data in the basis of age based? Provide answer to the question
Solve my code
Solve my code  import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.io.*; public class ChangeDetails extends HttpServlet{ public void doPost(HttpServletRequest request,HttpServletResponse
to solve the error - Java Beginners
to solve the error  class bubbleSort1{ public static void bubbleSort(int[] x) { int n = x.length; for (int pass=1; pass < n; pass++) { // count how many times // This next loop becomes shorter and shorter for (int i=0
help me to solve this question
help me to solve this question   A user needs to key in data into system in order to save data into array. The data are: a. Lecturer ID, Lecturer name, School, course code, course name, session, semester A user can edit the data
solve my question shortly
solve my question shortly  <html> <head> <script> function checkphoneNumber(number){ if(/[^\d ]/.test(number)){ alert('It should contain numbers [0-9] only!'); document.getElementById
I couldn't solve it
I couldn't solve it  *A customer who wants to apply for getting a car license should provide information about the brand of the car. *Then the customer receives a request ID from the office. *The customer's request (represented
plz help meto solve this question
plz help meto solve this question  for a file that exist what will be the length() method in the file class return
i dont no how to solve it pls
i dont no how to solve it pls   Calculate and display the sum of all prime number from 1 to 100 covert in java system codes
how to solve an internet connection problem
how to solve an internet connection problem  when i run my application it give me this error: Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not yet implemented the problem is that i don`t know
can interface solve this problem in java
can interface solve this problem in java  I have a JDialog which displays the calendar [from 2010-2020], i created this in a different class... this calander class. can interface solve this problem. If yes then how. pls
Please Help To Solve My Problem
Please Help To Solve My Problem  PHP I Have 6 Textbox and 1 ok button. 6 Textbox to Add the 6 Team Name. Each Team Name In String(Like- A,B,C,D,E,F... With B Team when A Team Play With B Team Again Then Generate Error. I Am Solve
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
i need help to solve this problem
i need help to solve this problem  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input and prints them in reverse order. and Show step by step what queue will look like
Check Digit Question not able to solve..
Check Digit Question not able to solve..   Hi, I need some help asap. I been stuck for this question for more than 3 days. Using Java. User needs to key in identification number (e.g. U0906931E) system check for the first
ModuleNotFoundError: No module named 'solve-some-problems'
ModuleNotFoundError: No module named 'solve-some-problems'  Hi, My... named 'solve-some-problems' How to remove the ModuleNotFoundError: No module named 'solve-some-problems' error? Thanks   Hi
ModuleNotFoundError: No module named 'solve-some-problems'
ModuleNotFoundError: No module named 'solve-some-problems'  Hi, My... named 'solve-some-problems' How to remove the ModuleNotFoundError: No module named 'solve-some-problems' error? Thanks   Hi
How to Solve the Syntax Error in java??
How to Solve the Syntax Error in java??  Syntax error in java? i have tried this program its showing error like this in Eclipse "Syntax error on token "i", VariableDeclarator expected after this token" . in last line
how do i solve this problem?
how do i solve this problem?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
plz anyone can solve my
plz anyone can solve my  creat an applet prog which accepts the details of 10 customers like name , address , city , ect. and display it   import java.awt.*; import javax.swing.*; import java.awt.event.*; import

Ads