Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: jsp- servlet problems

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up jsp- servlet problems

    hello friends!!!!!!!!!
    I want to read parameters from text field of jsp page on servlet page
    and further i want to insert these values in to database table named
    result table
    i am using the concept of MVC architecture.
    fallowing is the code below in consern

    .................................................. .................................................. ......................

    //on jsp page i have written below codes
    <tr>
    <td><input type="text" name="text1" readonly value="<%= Math.floor(Math.random()*101)%>" size="18"/></td>
    <td><input type="text" name="text2" readonly value="<%=Math.floor(Math.random()*101)%>" size="18"/></td>
    <td><input type="text" name="text3" readonly value="<%=Math.floor(Math.random()*101)%>" size="18"/></td>
    <td><input type="text" name="text4" readonly value="<%=Math.floor(Math.random()*101)%>" size="18"/></td>
    <td><input type="text" name="text5" readonly value="<%=Math.floor(Math.random()*101)%>" size="18"/></td>
    </tr>
    .................................................. .................................................. ..............................
    //on servlet i have written the codes below

    try{
    float s9=Float.parseFloat(request.getParameter("text1"). toString());
    System.out.print(s9);
    float s10=Float.parseFloat(request.getParameter("text2") .toString());
    System.out.print(s10);
    float s11=Float.parseFloat(request.getParameter("text3") .toString());
    float s12=Float.parseFloat(request.getParameter("text4") .toString());
    float s13=Float.parseFloat(request.getParameter("text5") .toString());
    System.out.print(s13);
    Time s14=Time.valueOf(request.getParameter("timetext")) ;
    System.out.print(s14);
    st7=conn.prepareStatement("insert into resulttable(result_time,50RS,100RS,200RS,300RS,500 RS,resno)"+
    "values("+Time.valueOf(request.getParameter("timet ext"))+","+request.getParameter("text1")+"','"+req uest.getParameter("text2")+"','"+request.getParame ter("text3")+"','"+request.getParameter("text4")+" ','"+request.getParameter("text5")+"'),"+1+"");
    //st7.setTime(1,s14);
    // st7.setString(2, s9);
    // st7.setString(3, s10);
    // st7.setString(4, s11);
    // st7.setString(5, s12);
    // st7.setString(6, s13);
    // st7.setInt(8, 1);
    int i=st7.executeUpdate();
    if(i==1)
    {
    response.sendRedirect("/jsp3/LotteryScreen.jsp");

    }else
    {
    response.sendRedirect("/jsp3/DispResult.jsp");
    }


    //when i run above code it transfer controls to server side but does not show any output and neither throw any exception
    I am totally confused what to do with the code?????????????????????????
    please help me?????????????????????
    Last edited by kundan_101; January 3rd, 2011 at 02:11 AM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: jsp- servlet problems

    Please define what you mean by 'does not work'? Does it run on the server? Exceptions being thrown? Behavior incorrect (if so, describe what you get versus what you want/expect)?

Similar Threads

  1. What are the requirements to develop Servlet Application?
    By yousef atya in forum Java Servlet
    Replies: 2
    Last Post: July 28th, 2011, 06:20 PM
  2. Servlet or Jsp?
    By flangofas in forum JavaServer Pages: JSP & JSTL
    Replies: 3
    Last Post: December 8th, 2010, 11:54 AM
  3. New Window from a Servlet
    By RookieServletPrgmer in forum Java Servlet
    Replies: 6
    Last Post: December 2nd, 2010, 08:52 AM
  4. Eclipse web.xml servlet mapping???
    By nikos in forum Java IDEs
    Replies: 2
    Last Post: October 24th, 2010, 05:30 AM
  5. servlet and socket plz HELP
    By Mokhtar in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 8th, 2010, 09:21 AM