Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process Empty screen after executing servlet
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Rajendra
Empty screen after executing servlet
2 Answer(s)      5 years and 6 months ago
Posted in : Development process



Advertisement
View Answers

July 16, 2009 at 12:02 PM


Hi Friend,

Please send your Servlet code.

Thanks


April 10, 2012 at 12:24 PM


<form action="srv2"  method="post">
    Enter The Item  <input type="text"  name="all"> EX : TOMATO , CAPISCOM , TAMARING , BRINJAL , POTATO , VANKAYA , KAKARKAYA , POTLAKAYA<br>
    <input type="submit"  value="click">
</form>



//==========================================================


<web-app>
    <servlet>
    <servlet-name>Val</servlet-name>
    <servlet-class>TableData</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Val</servlet-name>
        <url-pattern>/srv2</url-pattern>
    </servlet-mapping>
</web-app>

//==========================================================



import java.io.IOException;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class TableData  extends HttpServlet
{
    Connection con;
    Statement  st;
    public void init(ServletConfig sc)throws  ServletException
    {
        try
        {
        Class.forName("oracle.jdbc.driver.OracleDriver");
        con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","suresh");
        st=con.createStatement();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }

    public void doPost(HttpServletRequest req ,HttpServletResponse res)throws  ServletException,IOException
    {
        try
        {
        res.setContentType("text/html");
        ServletOutputStream sos=res.getOutputStream();
        String val=req.getParameter("all");
        ResultSet rs=st.executeQuery("select * from vegitablepurchase  where  item='"+val+"' ");
        if(rs!=null)
        {
           while(rs.next())
            {
            sos.println(" "+rs.getString(1)+"  "+rs.getString(2)+"   "+rs.getString(3)+"  "+rs.getString(4)+" ");
            }
            rs.close();
        }
        else
        {
            sos.println("rs not executed  , please rectify the  error......");
        }

        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }

    public void destroy()
    {
        try
        {
            st.close();
            con.close();
        }
        catch(Exception e)
        {
            System.out.println(e);
        }

    }

}


Related Tutorials/Questions & Answers:
Empty screen after executing servlet - Development process
Empty screen after executing servlet  Hi, After executing servlet am getting blank screen. Am using weblogic server and Eclipse editor...)Locate war file and deployed 5)Then test , but am getting empty screen . Plz give
Printing the integers before and after - JSP-Servlet
Printing the integers before and after  Hi, I'm trying to print out the integers before and after generated random number, and also stating it as either even or odd, but it does not seem to work. Pls advise on my code below
Advertisements
while executing a java program
while executing a java program  while iam executing a simple java program after i type "java simple.java" there was a an error occuring.the error is "exception in thread "main" java.lang.noclassdeffounderror:simple" what thus
Empty Elements in HTML
Empty Elements in HTML  What is Empty Elements in HTML
Screen Capture
Screen Capture  How to capture the screen using jsps and servlets
non empty file
Java Delete non empty file  f.delete() works when the file is empty.if a file be non empty how to delete it???   Please visit the following link: http://www.roseindia.net/tutorial/java/core/files
Screen shot
Screen shot  webpage screenshot source code
splash screen
splash screen  What is splash screen and how can i set splash screen in iphone??   hello, if you want to launch splash screen then add... splash screen will show launching time
how to disable back button of a browser after logging in? - JSP-Servlet
how to disable back button of a browser after logging in?  how to disable back button of a browser after logging in?  where is the source code
Logic Empty Tag (<logic:empty>...</logic:empty>)
Logic Empty Tag (<logic:empty>...</logic:empty>)        empty tag - If the requested variable is either null or an empty string then we use
Screen Capture
Screen Capture  Hi deepak, I am trying to take a screen shot using java script Activex object. But Iam getting Automation server cant create object exception .how can i solve
staying in same page after deliting arow in jsp page - JSP-Servlet
staying in same page after deliting arow in jsp page  Hello Sir, I want to stay back in current jsp page after deleting row in jsp table. how can i do this. need help from you. thanks, nandini  Hi friend
Clear the print button after onclicking the print - JSP-Servlet
Clear the print button after onclicking the print  rate_print.document.writeln(" "); hai sir, this is my java script code, i ask how to clear the printbutton image when after onclicking the print button....  Hi
ERRor in executing DB program
ERRor in executing DB program  While executing following code an Error was generated.can any one help me for this. LiveDB liveDBObj = DataSourceFactory.getLiveDBInstance(); PreparedStatement pstmt=null; String qry=""; qry
executing Hibernate application
executing Hibernate application  when i am executing the hibernate application the following error occured. log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). /hibernate.cfg.xml not found log4j
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  Dear All I created JSP... data. I dont want to see my old visited pages after logout or expire the session. Anyone having idea how to disable browser back button after logout, please
How to revert back ServletInputStream object after reading once. - JSP-Servlet
How to revert back ServletInputStream object after reading once.  Hi.... My Q is how can I iterate request object twice? How we can revert back ServletInputStream object after reading once? Please Help me...... Thanks in advance
How to disable browser back after logout - JSP-Servlet
How to disable browser back after logout  thanks deepak, i tried but if i am clicking back still i can see my old pages. i copied your code in my logout page. please if you have any other solution, please give me
Array Empty
Array Empty      ... to understand in an Array Empty. For this example we are using Java Scripting... document. write print an Array is empty. An array object hold the various element
Problem in executing query....
Problem in executing query....  Suppose there is a textbox or a text area and the user is supposed to enter any text.Suppose the user enters his text and his text contains a '(inverted comma) somewhere in his text.I fetch
Check if the directory is empty or not
Check if the directory is empty or not In this section, you will learn how to check if the directory is empty or not. Java IO package works with both files and directories. Here we are going to check whether directory is empty
Screen flashing
Screen flashing  Hey I am trying to make my screen flash (like a white flash as if from a camera). This is my code so far: <html> <... I want is that I want the screen to flash white when a link is clicked. Thanks
difference between touch screen and non touch screen
difference between touch screen and non touch screen  code wise ,what is a difference between touch screen and non touch screen in J2ME
difference between touch screen and non touch screen
difference between touch screen and non touch screen  what is a difference between touch screen and non touch screen in J2ME (code wise
Check Empty String
Check Empty String       In this example we are checking a sting object containing empty or null... is empty ("") , null or whitespace. isNotBlank(String str
Cannot assign an ArrayList to an empty ArrayList
Cannot assign an ArrayList to an empty ArrayList  I have a java file, in which a method returns an ArrayList. This ArrayList is supposed to contain all the Student object which are in X year. StudentsManager.java public
Caputuring screen shot
Caputuring screen shot  How to to capture screen shot for a computer on internet
Screen Flickers - Framework
Screen Flickers  One of my screen flickers. Is that is beacuse of less memory
Executing Set of SQL statements in Java
Executing Set of SQL statements in Java  Hi, I am trying to execute a procedure which is stored in MS SQL server's database. I have configured... the code for saving the data in excel but the code for executing the query
executing java program with 2 classes
executing java program with 2 classes  how to run a program of java containing more than one class....ex of program is given below.... class C...); } }   Executing java program with 2 classes save the file with D.java
Table Empty Cell in HTML
Table Empty Cell in HTML       The Table Empty Cell in HTML define no content inside a cell of table. The code is not able to display border around the empty cell in a table
Advertisements
 

 

 

DMCA.com