Empty screen after executing servlet

Ads

 
 

Share on Google+Share on Google+

Rajendra
Empty screen after executing servlet
2 Answer(s)      8 years ago
Posted in : Development process
Ads
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);
        }

    }

}

Ads









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
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
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
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
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
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
Empty Elements in HTML
Empty Elements in HTML  What is Empty Elements in HTML
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
Screen Capture
Screen Capture  How to capture the screen using jsps and servlets
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
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
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
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
Mantain a Session in one application after opening another third party application - JSP-Servlet
Mantain a Session in one application after opening another third party application  Hi My Requirements is like this.. I have one ear... or time out or expires in the Third Party Application. We can write a servlet
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
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
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
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
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
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
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
please give me solution how to display next page after 20 records ? - JSP-Servlet
please give me solution how to display next page after 20 records ?  Java Servlet Paging control example  here i have attached one example code. function validate() { for(j=0;j<30;j
Screen Flickers - Framework
Screen Flickers  One of my screen flickers. Is that is beacuse of less memory
Caputuring screen shot
Caputuring screen shot  How to to capture screen shot for a computer on internet
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
how to get a column values from a excel file after attaching it - JSP-Servlet
how to get a column values from a excel file after attaching it  hi sir, How to get a column values from a excel file after attaching it while sending a email,while sending a email if i attached a file that should be read
Screen Scraping - Ajax
Screen Scraping  How i can do the screen scraping using java and ajax
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

Ads

 
Advertisement null

Ads