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



Home Answers Viewqa JSP-Servlet unable to compile class file
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Shanthi
unable to compile class file
2 Answer(s)      6 years and 2 months ago
Posted in : JSP-Servlet



Advertisement
View Answers

October 24, 2008 at 10:21 AM


Hi,

<%@ page language="java" import = "java.util.*;"%>
<%
List userList;
int nouser;
int i=1;
List cityList;
int nocity;
int j=1;
%>
<%
userList=(ArrayList)request.getAttribute("useridList");
nouser = userList.size();
%>

<%
cityList=(ArrayList)request.getAttribute("cityList");
nocity=cityList.size();
%>
<html>
<head>
<title>dynamic bombobox in servlet</title>
</head>
<body>
<br><br>
<center>
<table border="1" width="300px" bgcolor="bluelight" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="GET" action="/examples/jsp/ComboboxList">
<font color="red"><h3 align="center">Dynamic Combobox List</font></h3>
<table border="1" width="300px" cellspacing="0" cellpadding="0">
<tr>
<td width="50%"><b>User Name:</b></td>
<td width="50%"><select name="userid" value="">
<option value="0">---Select Name---</option>
<%
Iterator userit= userList.iterator();
while(userit.hasNext()){
while(i<=nouser){%>
<option value="<%=i%>"><%=userit.next()%></option>
<%
i++;
}
}
%>
</select>
</td>
</tr>
<tr>
<td width="50%"><b>City:</b></td>
<td width="50%">
<select name="city" value="">
<option value="0">----Select city----</option>
<%
Iterator cityit= cityList.iterator();
while(cityit.hasNext()){
while(j<=nocity){%>
<option value="<%=j%>"><%=cityit.next()%></option>
<%
j++;
}
}
%>

</select>

</td>
</tr>

</table>

</form>
</td>
</tr>
</table>
</center>
</body>

</html>


October 24, 2008 at 10:22 AM


servlets code

package javacode;

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

public class ComboboxList extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String password="amar123";
try{
Class.forName(driver);
con = DriverManager.getConnection(url+db,userName,password);
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from Combolist");
List ulist = new ArrayList();
List clist = new ArrayList();
while(rs.next()){
request.setAttribute("userid", rs.getString(2));
request.setAttribute("city", rs.getString(3));
pw.println("userid" + " "+"city"+"<br>");
pw.println(rs.getString(2) + " " + rs.getString(3) +"<br>");
ulist.add(rs.getString(2));
clist.add(rs.getString(3));

}
request.setAttribute("useridList", ulist);
request.setAttribute("cityList", clist);
}
catch (Exception e){
pw.println(e);
}
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/jsp/Combobox.jsp");
dispatcher.forward(request, response);
}

}
---------------------------------------------


Read for more information.

http://www.roseindia.net/servlets/

Thanks.


Related Tutorials/Questions & Answers:
unable to compile class file - JSP-Servlet
unable to compile class file  I wrote database connection in jsp file. I have form in html. In html form i put drop down list box in that form...*; import java.util.ArrayList; public class ComboboxList extends HttpServlet
Unable to compile class for JSP - WebSevices
Unable to compile class for JSP  org.apache.jasper.JasperException: Unable to compile class for JSP When I am trying to access a java file kept under src folder under a package from a jsp page placed under web directory, I am
Advertisements
Unable to compile Servlet
Unable to compile Servlet  First I installed the tomcat server in C...\servlet-api.jar Then I created my servlet file Servlet_LifeCycle.java under... was created by me. To compile my servlet program I did the following: C:\apache
compile a java class
compile a java class  Hi, Am having a class ExampleOne.java in the location C:\learn\ExampleOne.java I want the class file to be present in C:\. I don't want to add any package details in the code. Is is possible to get
compile a java class
compile a java class  Hi, Am having a class ExampleOne.java in the location C:\learn\ExampleOne.java I want the class file to be present in C:\. I don't want to add any package details in the code. Is is possible to get
unable to import class com.opensymphony.xwork2.ActionContext not found
unable to import class com.opensymphony.xwork2.ActionContext not found  Imported class com.opensymphony.xwork2.ActionContext not found gettin the above error
compile
compile  how to compile .class files using eclipse
Unable to get data from class - Development process
Unable to get data from class  I get this code from the internet...*; import java.util.*; public class ComControl implements Runnable...; } } ========================================================================= In my other class, I have my desktop application which called
Unable to call .jrxml file from jsp
Unable to call .jrxml file from jsp  Hi, I am doing web application... plugin. After creating report in netbean when i call that jrxml file then it unable to access it.Error also not showing. I will show my code and its output
Example to compile a java file with the help of the program
Example to compile a java file with the help of the program... are describing you the way to compile the java file with the help of the java program... below: For this we are taking a class Compile Hello, Inside the main method we
How to compile PHP file and provide it to user without code?
How to compile PHP file and provide it to user without code?  I have created a class in PHP, that contains some useful methods. Now I want to give... in asp.net instead of providing code file. How can I compile the PHP file and provide
class file
class file  How to create class file in jsf easily
file class
file class  Hi Friend, I have a file class it lets me extract all the data from a csv file but I need to align the data properely, seperating... java.util.*; public class ReadCSV{ public ReadCSV (){ } public static
class file
class file  how to convert java classfile into java sourcefile
Java file class
Java file class  What is the purpose of the File class
about the base class of file
about the base class of file  what is the basic class of file
JAVA Compile Question ?
JAVA Compile Question ?  I'm unable to compile this file and not sure... java.io.IOException; public class FileStatistics2 { public static void main(String[] args...("The text file is " + ratio + "% of the size of the word file
compile error
compile error  Hello All for example public class... program with Test.java and try to compile with javac test.java an error like test.java :2 : class A is public ,should be declared in a file named A.java
Java class file
Java class file  How do i open a java class file using eclipse
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
bad class file - JSP-Servlet
) and got a "bad class file...): myservlet.java:9: cannot access HttpServlet bad class file: \HttpServlet.class...bad class file. I'm (desperately) trying to get... api.jar file that you have downloaded from class path.Find servlet-api.jar from
Using Ant to execute class file
Using Ant to execute class file       This build.xml file is used to compile and run...;; third one is used to compile the java file from "src" directory
how to compile programs??????????
how to compile programs??????????  "javac" is not recognised as a file name. why??????????   Have you set your path name and class name correctly? Anyways have a look at the following link: Install Java
Convert Class File to .java File - Java Beginners
Convert Class File to .java File  Sir, How To Convert .class file to .java File. Please Help me  Use cavaj software ,which is freeware, to convert .class to .java  Use jd-gui to convert ur .class to .java
Compile error - WebSevices
Compile error  Hello, How to read .pdf file using Javascript/php. Any one send the code
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
compile time error
compile time error  my program compile successfully and make the class file also but when i tried to do next command to see the output,it showing error that "could not find or load main class fibbo" fibbo is my class name
How to compile and run the JSP
How to compile and run the JSP  Hi Kindly tell me how to run and compile JSP small Program using Tomcat as webserver. I created small program HELLO JSP in HTML and compile the program but it is saying Class o r interface
compile and run java program
compile and run java program  Hello, everyone!!! I just want to ask if you anyone here knows how to compile java file in linux specifically UBUNTU... do I compile and run this file using the terminal of ubuntu... By the way, I am
unable to run servlet
unable to run servlet  Dear sir/madam i have jdk1.5.0_04 and tomcat...*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet...-mapping> 6)Compile your servlet. 7)Run Tomcat server by clicking
 

 

 

DMCA.com