unable to compile class file

unable to compile class file

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
class file
class file  How to create class file in jsf easily
class file
class file  how to convert java classfile into java sourcefile
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
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
Unable to upload a file to mysql database using struts1
Unable to upload a file to mysql database using struts1  Hi, Below...=new FileInputStream(file);* in the above action class i.e UploadAction.java...="multipart/form-data"> Select a File :<html:file property="file"/> <
compile
compile  how to compile .class files using eclipse
about the base class of file
about the base class of file  what is the basic class of file
Java class file
Java class file  How do i open a java class file using eclipse
Java file class
Java file class  What is the purpose of the File class
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
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
compile
compile  how to compile a java program using jre7
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
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
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
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
Class and interface in same file and accessing the class from a main class in different package
Class and interface in same file and accessing the class from a main class... a class named CantFly in same file. A main method CheckAnimal.java. Below.... I tried searching for solution, but was unable to find one. Below is my query
Class and interface in same file and accessing the class from a main class in different package
Class and interface in same file and accessing the class from a main class... a class named CantFly in same file. A main method CheckAnimal.java. Below.... I tried searching for solution, but was unable to find one. Below is my query
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
If I open .class file with notepad what is displayed?
If I open .class file with notepad what is displayed?   What is displayed when we open java .class files with notepad
xcode unknown class in interface builder file
xcode unknown class in interface builder file  What is the unknown file in xib or how can i find and remove such kind of exception from my file.. "xcode unknown class in interface builder file
Difference in size of .java & its respective .class file
Difference in size of .java & its respective .class file  Hai, I had created & compiled a java class named sample.java. The size of sample.java is 340KB. Whereas the size of its respective class file sample.class is 137KB
Java class name and file name are different
Java class name and file name are different  Can we run a Java program having class name and file name different?   Hi Friend, No, you can't. It is necessary to save the java file with its class name otherwise
Is there a data structure like a class that doesn't need to be defined as a class in it's own file?
Is there a data structure like a class that doesn't need to be defined as a class in it's own file?  I am new to java, and I am trying to make... like a class without having to make a whole new file to define it, so I could
Decompress file using Inflater class.
Decompress file using Inflater class. In this tutorial, we will define the use... Example, we will explain how to decompress file using Inflater class. The Inflater... and read  bytes from file. The InflaterInputStream class creates a input
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.UnsupportedClassVersionError: Bad version number in .class file...java.lang.UnsupportedClassVersionError: Bad version number in .class file  My java servlet not working correctly on my website. I have tried every
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
creating new file with File class - JSP-Interview Questions
of FileOutputStream class. If we give the path as from the file uploading location will it work...creating new file with File class   I have a file uploading concept in my project. For that, while creating a new file is it necessary to give
download file Error in struts2 action class
download file Error in struts2 action class  Hi, i am using bellow block of code for download file : public void downloadGreeting(String... strPrefix = System.getProperty("astsoundsfolderoriginal"); File
How to Compress file using DeflaterOutputStram class in java.
How to Compress file using DeflaterOutputStram class in java. In this tutorial... will compressed the data of a file by using DeflaterOutputStream class... class creates a input stream for reading data from a file. The setLevel() method
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
How to Compress file using Deflater class in java
How to Compress file using Deflater class in java. In this Example, we will discuss  how to use Deflater class in java. The Deflater class is used.... In this Example, we will compressed the data of a file. The Defleter class create
How to convert many class files into one exe file?
How to convert many class files into one exe file?  How to convert class files into one exe file? I have done my project in java.i want to know how to convert it into .exe file? plz reply fast. Thnx in Advance. Happy Pongal
How to convert many class files into one exe file?
How to convert many class files into one exe file?  How to convert class files into one exe file? I have done my project in java.i want to know how to convert it into .exe file? plz reply fast. Thnx in Advance. Happy Pongal
I want to know the given class name exists in which jar file?
I want to know the given class name exists in which jar file?   I want to know the given class name exists in which jar file? C:\Program Files\IBM... the name of the jar file where 'com.rational.ft.util.debug' class exists
how to send my system.out.println in a class file to a jsp in Struts2
how to send my system.out.println in a class file to a jsp in Struts2   System.out.println("File" + f + " contains text " + text + " at line " + hm1.keySet() + " and index "+ hm1.values() ); I want
How to rectify "Bad version number in .class file" exception in Eclipse
How to rectify "Bad version number in .class file" exception in Eclipse ... this request. exception javax.servlet.ServletException: Bad version number in .class file org.apache.jasper.servlet.JspServlet.service(JspServlet.java:274
how to access the messagresource.proprties filevalues in normal class file using struts - Struts
how to access the messagresource.proprties filevalues in normal class file using struts  i want to access the below username and password in class... password=system My class file is import java.io.PrintStream; import
unable to connect database in java
unable to connect database in java  Hello Everyone! i was trying to connect database with my application by using java but i am unable to connect... created. 6) Restart your compiler and compile your java code. For Inserting Data
how to call java script function through java class file
how to call java script function through java class file  how to call jframe in java script
unable to execute the examples
unable to execute the examples  unable to execute the examples given for struts,ejb,or spring tutorials.Please help I am a beginner
how to convert jsp page to class file - JSP-Servlet
how to convert jsp page to class file  hai. iam doing online banking project by using jsp.i completed all the jsp pages.next can you tell me how to convert these jsp pages to class files with example and where to copy these class
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

Ads