Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a Java Expert!

Join 244,265 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,168 people online right now. Registration is fast and FREE... Join Now!




JSP using a combo box

 
Reply to this topicStart new topic

JSP using a combo box

nick2price
30 Dec, 2008 - 05:15 AM
Post #1

D.I.C Addict
****

Joined: 23 Nov, 2007
Posts: 962



Thanked: 83 times
My Contributions
Having major problems, really not that good at html, but this is to do with jsp. Basically i have 2 combo box's. The user selects a value from each of them, and these values are sent to my database with the results being printed back to a new html page. So i have my html source here
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>London 2012</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style4 {
    font-size: 14px;
    font-weight: bold;
    font-style: italic;
}
.style5 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-style: italic;
    font-size: 14px;
}
-->
</style>
</head>

<body>
<table width="884"><td width="884"><img src="mainPageTitle.jpg" alt="" name="topPanel" width="884" height="143" border="4"></td>
</table>
<table>
<td background="registerImage.jpg">

<form name="form1" method="post" action="servlet/Register">
  <p><span class="style5">Full Name</span><span class="style4">:</span>
    <input name="fullName" type="text" id="FullName">
  </p>
  <p><span class="style5">User Name:</span>
    <input name="userName" type="text" id="userName">
  </p>
  <p><span class="style5">Password</span><span class="style4">:</span>    
    <input name="passWord" type="text" id="passWord">
  </p>

  <p align="center">
    <input type="submit" name="Submit2" value="Register">
  </p>
</form></td>
<td><img name="centerPanel" src="mpCPanel.jpg" width="394" height="472" alt=""></td>

<td height="482" bordercolor="#000099" background="logInImage.jpg">



<form name="form1" method="post" action="servlet/Login">
  
  <p><span class="style5">User Name:</span>
    <input name="userName" type="text" id="userName">
  </p>
  <p><span class="style5">Password:   </span>    
    <input name="passWord" type="text" id="passWord">
  </p>

  <p align="center">
    <input type="submit" name="Submit" value="Login">
  </p>
</form></td>

</table>
</body>
</html>


I dont know if i have set it up properly to hold a value in some sort of variable. But then when it comes to my jsp, i am doing this
CODE
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;



public class SearchEdit extends HttpServlet {
    
    DatabaseSQL dBase = new DatabaseSQL();

    public void doPost(HttpServletRequest request,
            HttpServletResponse response)
    throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        out.println("<html>");
        out.println("<head>");
        
        String title = "Search/Edit";
        
        out.println("<title>" + title + "</title>");
        out.println("</head>");
        out.println("<body bgcolor=\"blue\">");
        out.println("<h1>" + title + "</h1>");
        try{
            String eventType = request.getParameter("Events");
            String roundType = request.getParameter("Rounds");
            List<UpdateEventSetGet> searchResult = dBase.searchRecords(eventType, roundType);
            
                for(int x = 0, y = searchResult.size(); x < y; x++) //loop size of result
                {
                    UpdateEventSetGet update = searchResult.get(x); //put results into objects
                    
    
                    out.println(update.getNationality() + "<br>"); //assign each variable of object to a position in JTable
                    out.println(update.getFirstname() + "<br>");
                    out.println(update.getLastname() + "<br>");
                    out.println(update.getTime() + "<br>");
                    
                    
                }
            }
    catch (Exception e) {
            out.println("<p>Please make sure you select all required fields");
            e.printStackTrace();
            }
        out.println("<a href=\"../searchEdit.html\">Back</a>");
        out.println("</body>");
        out.println("</html>");
    }
}


When i click on the search button, it takes me to the jsp page but just shows the title. Do i have to make a change to my combo box's or somthing?
any help would be appreciated.
thanks

User is online!Profile CardPM
+Quote Post


Christopher Elison
RE: JSP Using A Combo Box
30 Dec, 2008 - 08:43 AM
Post #2

D.I.C Head
**

Joined: 29 Dec, 2008
Posts: 83



Thanked: 10 times
My Contributions
Are you sure that's the right HTML? Your JSP is expecting the parameters 'Events' and 'Rounds' to be passed to it from your HTML form, although there are no fields in your HTML form named 'Events' or 'Rounds'.
User is offlineProfile CardPM
+Quote Post

nick2price
RE: JSP Using A Combo Box
30 Dec, 2008 - 08:57 AM
Post #3

D.I.C Addict
****

Joined: 23 Nov, 2007
Posts: 962



Thanked: 83 times
My Contributions
lol, my bad, posted wrong html. I have found out some information, just wanna make sure it is ok. Really, i shouldnt be using html extensions? All the html work should be done in my jsp pages?
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 12:38PM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month