Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

data grid with edit and delete options

 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
edit and delete option at each row of table using servlet and mysql
 
Sheriff
Posts: 22120
114
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please:
- EaseUp. There is no such thing as urgent around here.
- QuoteYourSources. You mention roseindia but a link would be nice.
- TellTheDetails. You haven't given us much information, so we won't really be able to help you out.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest to keep away from roseindia.net. It is having examples with bad practices and is poorly designed.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:I would suggest to keep away from roseindia.net. It is having examples with bad practices and is poorly designed.



thanks for your suggestion.
my problem is this i am having servlet page with table and i want that table data to be editable when i click on edit button that is available with each row of table and also i can able to delete a particular row.
when i click on edit button it should take me to editable page where i can make changes in the data and click on save button so that data can go in database as well as the home page. also there is facility that i can add new record in that also when i click on add new details link it will take me to new page where i can add details and click on save button so that new records are added in database as well as it will reflect on home page.

for this i have to use servlet and mysql
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Till now what you have done? Show us the code and other relevant things and tell what problems you are facing. As Rob already said, TellTheDetails..
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

You can have a look ti JQGrid http://www.trirand.com/blog/jqgrid/jqgrid.html
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:Till now what you have done? Show us the code and other relevant things and tell what problems you are facing. As Rob already said, TellTheDetails..



Below is the code
"import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;

public class AddUser extends HttpServlet{

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

System.out.println("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

String username = request.getParameter("username").toString();
String first_name = request.getParameter("first_name").toString();
String last_name = request.getParameter("last_name").toString();
String city = request.getParameter("city").toString();
String state = request.getParameter("state").toString();
String country = request.getParameter("country").toString();


Statement stmt;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url+dbName,userName,password);
System.out.println("Connected to the database");

ArrayList al=null;
ArrayList userList =new ArrayList();
String query = "insert into userregister set username='"+username+"',first_name='"+first_name+"',last_name='"+last_name+"',city='"+city+"',state='"+state+"',country='"+country+"'";
stmt = conn.createStatement();

int i = stmt.executeUpdate(query);
System.out.println("query" + query);
if(i>0)
{
response.sendRedirect("ServletRecord");
}
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}
}
and i am getting below error

HTTP Status 405 - HTTP method GET is not supported by this URL

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

type Status report

message HTTP method GET is not supported by this URL

description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

i tried to override the get and post method but still error doesn't remove infact errors increase...

 
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Megha,

The error what you are getting hasn't go much to do with you code. In your code you are writing the doPost method. But how is the servlet invoked? Do you have any form and if so, what is the method type for form submission. It's always better to override both doPost and doGet method.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swastik Dey wrote:It's always better to override both doPost and doGet method.


Agree
But, Having both doGet and doPost do the same thing, is not good, they both are there for different purposes..
 
Swastik Dey
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Right, but nothing wrong it's doing the same processing.
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prasad Krishnegowda wrote:I would suggest to keep away from roseindia.net. It is having examples with bad practices and is poorly designed.



can't agree more, it is very bad.

I presume you are selecting data from the database, displaying it on screen and then letting the user edit this data.

Well i would pass the ID back to the form, and incorporate that into the edit and delete buttons.
 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is because your form method is GET (i believe) and the code you have written is in doPost().
and for your problem you should add three or whatever submit buttons in your form and check for post of each submit in your servlet, and perform the operations.
like:


and to make the text boxes editable or non-editable you can use js.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
or you can also do it like this
check for the values of your submit buttons in your servlet, and perform operation correspond to the value of your submit button.
i mean create submit buttons of same names, getPrameter into your servlet and check for the button value.



i do like this.
 
Megha Singhal
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Punit Jain wrote:or you can also do it like this
check for the values of your submit buttons in your servlet, and perform operation correspond to the value of your submit button.
i mean create submit buttons of same names, getPrameter into your servlet and check for the button value.



i do like this.



thanks to all for your suggestions i try to implement your methods..
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


thanks to all for your suggestions i try to implement your methods..


your welcome.
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic