Home Answers Viewqa JSP-Servlet convert jsp to servlet

 
 


megha singhal
convert jsp to servlet
2 Answer(s)      a year and a month ago
Posted in : JSP-Servlet

how to convert following code into servlet

int i=0;
while(rs.next())
{
%>
<tr>
    <td>
        <input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid") %>>
    </td>

    <td>
        <%= rs.getString("bookid") %></td><td><%= rs.getString("author") %>
    </td>

        <td>
            <%= rs.getString("title") %>
        </td>

    </tr>

    <%i++; 
View Answers

April 23, 2012 at 6:03 PM


Here is your required code:

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

public class Servlet extends HttpServlet{ 
  public void doGet(HttpServletRequest request, 
  HttpServletResponse response)
  throws ServletException,IOException{
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
   response.setContentType("text/html");
   out.println("<form name=myname method=post action=edit.jsp><table border=1><tr><td></td><td><b><u>bookid</u></b></td><td><b><u>Author</u></b></td><td><b><u>title</u></b></td></tr>");
   try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://192.168.10.112:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; 
while(rs.next()){
    out.println("<tr><td><input type=checkbox name=check"+i+" value="+rs.getString("bookid")+"></td><td>"+rs.getString("bookid")+"</td><td>"+rs.getString("author")+"</td><td>"+rs.getString("title")+"</td></tr>");
i++;
}
}
catch(SQLException e){
    System.out.println(e.getMessage());
    }
    out.println("</table><input type=submit></form></html>");
  }
}

April 23, 2012 at 6:03 PM


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

public class Servlet extends HttpServlet{ 
  public void doGet(HttpServletRequest request, 
  HttpServletResponse response)
  throws ServletException,IOException{
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
   response.setContentType("text/html");
   out.println("<html><form name=myname method=post action=edit.jsp><table border=1><tr><td></td><td><b><u>bookid</u></b></td><td><b><u>Author</u></b></td><td><b><u>title</u></b></td></tr>");
   try{

Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://192.168.10.112:3306/mysql","root", "root");
ResultSet rs = null;
Statement st=null;
st=conn.createStatement();
rs = st.executeQuery("select * from book");
int i=0; 
while(rs.next()){
    out.println("<tr><td><input type=checkbox name=check"+i+" value="+rs.getString("bookid")+"></td><td>"+rs.getString("bookid")+"</td><td>"+rs.getString("author")+"</td><td>"+rs.getString("title")+"</td></tr>");
i++;
}
}
catch(SQLException e){
    System.out.println(e.getMessage());
    }
    out.println("</table><input type=submit></form></html>");
  }
}









Related Pages:
convert jsp to servlet
convert jsp to servlet  how to convert following code into servlet int i=0; while(rs.next()) { %> <tr> <td> <input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid
Convert String to Class - JSP-Servlet
Convert String to Class  Hi all, I am using Quartz as a scheduler to execute my job. For scheduling job, used xml as a configuration file. Reading job name, class name, day & time using xml file only. Problem is while
how to convert a .xlsx to .xls fil - JSP-Servlet
how to convert a .xlsx to .xls fil  Dear sir, How to convert a .xlsx file to .xls using poi .Please give me some clue.... Thanks in advance
convert javascript var to java variable - JSP-Servlet
convert javascript var to java variable  hi how to conver javascript var to java variable?  Hi Friend, We are providing you two ways: 1)a.jsp: function call(){ var name = "roseindia
how to convert jsp page to class file - JSP-Servlet
how to convert jsp page to class file  hai. iam doing online banking project by using jsp.i completed all the jsp pages.next can you tell me how to convert these jsp pages to class files with example and where to copy these class
servlet - JSP-Servlet
servlet  How to convert multiple servlets into a single servlet,without increasing number of html files
jsp - JSP-Servlet
jsp  Hi, i already posted the question .i didnt get the response. please send me the answer very urgent. How to convert text to speech using jsp code. Regards, Valarmathi  Hi Friend, For converting Speech
javascript - JSP-Servlet
javascript  how to convert a string to long in javascript
jsp code problem - JSP-Servlet
jsp code problem  i want to make the bill from the barcode. how do i convert a barcode into a decimal number
how to convert jsp to exe
how to convert jsp to exe  hello sir, i am doing... tomcat5.0,j2se5.0 and jsp,servlets i am using.this is doing in localhost only. now i want... to another system. so i want to convert this to exe. that will executed only internet
JSP code - JSP-Servlet
JSP code  Hi! Can somebody provide a line by line explanation... the content type information from the jsp header. Then check the two conditions... the length of the content type, the method request.getContentLength() is used. Convert
pdf format - JSP-Servlet
pdf format  hi Sir, how to convert text format into PDF format. thanks & regards, vijayababu.m
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
convert this html form to jsp
convert this html form to jsp  <html> <head> <script... Village Registration --> </body></html>   JSP page...: http://www.roseindia.net/jsp/formdata.shtml JSP Tutorials
convert html to excel using jsp
convert html to excel using jsp   i want to convert a html page into mcrosoft excel page using jsp.how i do
servlets - JSP-Servlet
servlets  How would you set an error message in the servlet,and send the user back to the JSP page?Please give java or pseudo code examples.  ...("javax.servlet.error.exception_type"); // Convert the attributes to string
Exceptions - JSP-Servlet
Exceptions   Hello, Iam doing a web based JSP... only. After getting this i convert this value using Integer.parseInt() method... the problem. Here is the code: To get the value from text box and to convert
date format - JSP-Servlet
date format  how to convert 2008-10-14 to 14-Sep-2008   Hi friend, Code to convert "2008-10-14" to "14-Oct-2008" import java.util.Date; import java.text.*; public class SimpleFormatDate1 { public static
sending a mail - JSP-Servlet
sending a mail   I m writing a code for send mail in jsp,i sending... to convert from string to String[] here is whaString[] i have done //In html... Attach : //In jsp... String strFileAttachment = request.getParameter
Array Creation - JSP-Servlet
Array Creation  hi i have a requirement in which i need to convert 10000 comma separated string into multiple arrays , that is suppose i have got 1000 comma separated string values now i convert it into single array like
ajax in java - JSP-Servlet
: "login.php"   Hi friend, Do some changes to convert in JSP...ajax in java  The below code is for a php page but I want this in JSP page. function postRequest(strURL){ var xmlHttp
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value.   Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/servlet/passParameters.html
arraylist problem - JSP-Servlet
and POST methods. * @param request servlet request * @param response servlet response */ /* * To change this template, choose Tools... end) AS Total_Calls from sample1.dbo.check5 where convert(varchar(10),[date],101
arraylist problem - JSP-Servlet
servlet request * @param response servlet response...) AS Total_Calls from sample1.dbo.check5 where convert(varchar(10),[date],101..._calls from sample1.dbo.check5 WHERE convert(varchar(10),[date],101) BETWEEN '"+sd1
jsp/servlet - JSP-Servlet
jsp/servlet  How to create and save the excel file on given location using jsp/servlet?  hi Geetanjali, Read for more information, http://www.roseindia.net/jsp/poi/excelPOI.shtml Thanks
To store date - JSP-Servlet
format only. If it is possible to convert from integer to date send me... in details : http://www.roseindia.net/jsp/fileupload.shtml Thanks
Programming Error - JSP-Servlet
Programming Error  Hello Sir, how to convert a txt written in textarea of html must get converted to integers and should get displayed in words in count text box of htmt . And shoukd displayed in words Eg: if "Hello
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
Probem while creating PDF through JSP-Servlet - JSP-Servlet
java app or the batch file through JSP or servlet the PDFCreator is called but I...Probem while creating PDF through JSP-Servlet  Hi, I have a web-app in which I want to convert MS-Office documents to PDF online. I'm using
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
JSP - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
servlet and jsp - JSP-Servlet
servlet and jsp  can any one give me jsp-servlet related project-its urgent- 1-chat application 2-bug tracking system 3-online shopping 4-online...://www.roseindia.net/jsp/bank.shtml Thanks
servlet/jsp - JSP-Servlet
servlet/jsp  hi, get me the source code to upload all file formats in servlet/jsp plaese help me as soon as possible its urgent!!! by saravanan.k  Hi friend, Code to help in solving the problem
Servlet - JSP - JSP-Servlet
Servlet - JSP  i used arraylist in servlet as shown ArrayList total = new ArrayList (); ... total.add(k[i]); session.setAttribute("efg",total); when I code this like in my jsp <%ArrayList<Integer> data= new
JSP,Servlet - JSP-Servlet
JSP,Servlet  How can i pass a list of objects from jsp to an Action? Please help me to do
servlet and jsp - JSP-Servlet
servlet and jsp  Hello folks, I am very new JDBC. I am doing a project on java messaging service on the part of the project we are using JDBC. In my...   write in the jsp form action="path of servlet" and wirite
servlet and jsp - JSP-Servlet
servlet and jsp  Hi friend, please show one sample program, how to connect jsp and servlet using backend a ms-access.  Hi friend,<%@ page language="java" import="java.sql.*,java.util.*,java.text.*"
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
jsp/servlet - JSP-Servlet
jsp/servlet  Hello ! How can we call a servlet on a link on html page like a href="servletname"> Call Servlet Is it possible?   Hi friend, I am sending simple application using servlet. This is form
JSP - Abobe Interactive Forms - JSP-Servlet
JSP - Abobe Interactive Forms  Dear Gurus, Hi! I have a problem... TomCat Webserver. I dont know how to proceed. I have to make a JSP page which will retrieve the data from the Abobe Form which my clients will fill in and Convert
servlet/jsp - JSP-Servlet
servlet/jsp  Thanks for ur feedback! But this program shows an error showing package.org.apache.commons.fileupload.servlet does not exists package.org.apache.commons.fileupload.disk does not exists
on servlet - JSP-Servlet
on servlet deployment  What we'll get on servlet deployment
Jsp-Servlet
Jsp-Servlet  how can i display the values in jsp pages as list from servlet ? can you help me out plz ? thanks
Servlet - JSP - JSP-Servlet
Servlet - JSP  Here is my complete code. all my code is running with out any error. the for loop in servlet is running as many times as my checkboxes... Servlet Code: ---------------------- package com.servlet; import
JSP & Servlet - JSP-Servlet
JSP & Servlet  In the process of login validation. i'm entering the username correct and pass wrong. when using response.sendRedirect() a new req... help me with coding ? i'm just a beginner with JSP and sServlets
JSP & Servlet - JSP-Servlet
JSP & Servlet  Its an IBM Question In the process of login validation. i'm entering the username correct and pass wrong. when using... is wrong ? can any one help me with coding ? i'm just a beginner with JSP
jsp/servlet - JSP-Servlet
jsp/servlet  Hello friends ! I want to create columns in a table at run time everyday. I am using mysql database.how should I do it? thanks in advance  Hi friend, Plz explain your problem in details to solve

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.