Vector to JSP Page
Hello,
I have a certain Vector within my servlet class that i retrieve from my logic unit tier.
I wish to pass this Vector to the JSP page to view and use the following statements to do this :-
Vector aucItems = logic.getAuc() ;
request.setAttribute("aucItems", aucItems) ;
rd.forward(request, response);how would i go about displaying the contents in my JSP page ? i am aware i should use request.getAttribute("aucItems") to retrieve the Vector but how would i go about traversing the vector and extracting and displaying the information using the .getName() method on each object of the Vector
Thanx,
- FaeLLe
It thinks that your items variable aucItems is a
string, and is iterating through each character in
the string in this loop.
Put the ${ } signs around aucItems to tell it
otherwise.
ie:
<c:forEach var="aucItem" items="${aucItems}">
Cheers,
evnafetsHi,
I tried that just now
My new JSP file looks like this
<html>
<head>
<title>ITEMS ON AUCTION</title>
</head>
<body>
<%@page import="auction.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="aucItems" scope="page" class="java.util.Vector" />
<jsp:useBean id="aucItem" scope="page" class="auction.Auction" />
<table>
<c:forEach var="aucItem" items="$(aucItems)">
<tr><td>Item Number : </td><td><c:out value="${aucItem.itemNo}"/></td></tr>
<tr><td>Name : </td><td><c:out value="${aucItem.name}"/></td></tr>
<tr><td>Description : </td><td><c:out value="${aucItem.desc}"/></td></tr>
<tr><td>Current Bid : </td><td><c:out value="${aucItem.bid}"/></td></tr>
<tr><td>Maximum Bidder : </td><td><c:out value="${aucItem.maxBidder}"/></td></tr>
<tr><td>Seller Id : </td><td><c:out value="${aucItem.sellerId}"/></td></tr>
<tr><td>Maximum Time Of Auction : </td><td><c:out value="${aucItem.maxTime}"/></td></tr>
<tr><td>Auction Start Hour</td><td><c:out value="${aucItem.startHour}"/></td></tr>
<tr><td>Auction Start Min </td><td><c:out value="${aucItem.startMinute}"/></td></tr>
<tr><td>Auction Start Seconds </td><td><c:out value="${aucItem.startSeconds}"/></td></tr>
</c:forEach>
</table>
</body>
</html>I tried a lot of things for over eight hours now it always thinks it is a String.
Kindly assist.
Could it be because i have to perform a getAttribute() on the request parameter ?
Similar Messages
-
Hi All,
Can anybody please tell me as how I can pass vectors from a page to another page and how Can I retieve the value from the next page?
Thanks,
AarthyI am using this code in the first page
request.getSession.setAttribute("vec",v2);In the Recipient page
Vector v5=new Vector();
v5=(Vector)request.getSession().getAttribute("vec");I am getting nullPointerException when i try to get
the size of the vector.Can anyone tell as where I am
going wrong?
Thanks,
AarthyHow did u delclare your vector v2
did u say
Vector v2 = new Vector()
session.setAttribute("vec",v2);
if you just have said
Vector v2 ;
session.setAttribute("vec",v2);
and trying to access v2.size() will throw NULL pointer exception
good luck
KM -
[b]Error during JSP page processing[/b]
hi , i'm mech.
i have some probs with jsp. i am trying to connect jsp page with database and printing the data on the browser page. i have created DSN mm using microsoft odbc for oracle and oracle9i's driver oracle in orahome90 but it is giving yet . i have this coding and error.
------------------------jsp code--------------------------
package pagecompile.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Vector;
import com.sun.server.http.pagecompile.jsp.runtime.*;
import java.beans.*;
import com.sun.server.http.pagecompile.jsp.JspException;
import java.sql.*;
public class _Connect extends HttpJspBase {
static char[][] jspxhtml_data = null;
public _Connect( ) {
private static boolean jspxinited = false;
public final void jspxinit() throws JspException {
ObjectInputStream oin = null;
int numStrings = 0;
try {
FileInputStream fin = new FileInputStream("E:\\JavaWebServer2.0\\tmpdir\\default\\pagecompile\\jsp\\pagecompile.jspConnect.dat");
oin = new ObjectInputStream(fin);
jspxhtml_data = (char[][]) oin.readObject();
} catch (Exception ex) {
throw new JspException("Unable to open data file");
} finally {
if (oin != null)
try { oin.close(); } catch (IOException ignore) { }
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
boolean jspxcleared_due_to_forward = false;
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
String _value = null;
try {
if (_jspx_inited == false) {
jspxinit();
jspxinited = true;
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html");
pageContext = _jspxFactory.getPageContext(this, request, response,
"", true, 8192, true);
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
out.print(_jspx_html_data[0]);
out.print(_jspx_html_data[1]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(14,2);to=(28,2)]
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection myconn=DriverManager.getConnection("Jdbc:Odbc:mm","madhulika","madhulika");
Statement stmt = myconn.createStatement();
ResultSet myResultSet = stmt.executeQuery("Select * from peopletable");
if(myResultSet != null)
while(myResultSet.next())
int eid=myResultSet.getInt("id");
String fname=myResultSet.getString("firstname");
String lname=myResultSet.getString("lastname");
String mail=myResultSet.getString("email");
// end
out.print(_jspx_html_data[2]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(30,10);to=(30,13)]
out.print(eid);
// end
out.print(_jspx_html_data[3]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(31,10);to=(31,15)]
out.print(fname);
// end
out.print(_jspx_html_data[4]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(32,10);to=(32,15)]
out.print(lname);
// end
out.print(_jspx_html_data[5]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(33,10);to=(33,14)]
out.print(mail);
// end
out.print(_jspx_html_data[6]);
// begin [file="E:\\JavaWebServer2.0\\public_html\\Connect.jsp";from=(37,5);to=(43,0)]
stmt.close();
myconn.close();
// end
out.print(_jspx_html_data[7]);
} catch (Throwable t) {
if (out.getBufferSize() != 0)
out.clear();
throw new JspException("Unknown exception: ", t);
} finally {
if (!_jspx_cleared_due_to_forward)
out.flush();
_jspxFactory.releasePageContext(pageContext);
-------------------error in browser----------------------
Error during JSP page processing
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at java.lang.Throwable.(Compiled Code)
at java.lang.Exception.(Compiled Code)
at java.sql.SQLException.(SQLException.java:43)
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Compiled Code)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:3814)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:1029)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:145)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:165)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:126)
at pagecompile.jsp._Connect._jspService(Compiled Code)
at com.sun.server.http.pagecompile.jsp.runtime.HttpJspBase.service(HttpJspBase.java:87)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.runServlet(JspServlet.java:469)
at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.processJspPage(JspServlet.java:259)
at com.sun.server.http.pagecompile.jsp.runtime.JspServlet.service(JspServlet.java:97)
at javax.servlet.http.HttpServlet.service(Compiled Code)
at com.sun.server.ServletState.callService(ServletState.java:226)
at com.sun.server.ServletManager.callServletService(ServletManager.java:936)
at com.sun.server.ProcessingState.invokeTargetServlet(ProcessingState.java:423)
at com.sun.server.http.HttpProcessingState.execute(HttpProcessingState.java:79)
at com.sun.server.http.stages.Runner.process(Runner.java:79)
at com.sun.server.ProcessingSupport.process(Compiled Code)
at com.sun.server.Service.process(Service.java:204)
at com.sun.server.http.HttpServiceHandler.handleRequest(HttpServiceHandler.java:374)
at com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code)
at com.sun.server.HandlerThread.run(CompiledBacking up a moment, is there a particular reason that you're using the JDBC-ODBC bridge rather than using the Oracle JDBC driver?
Have you taken a look at the JSP sample code available on OTN? I would start by making sure you can run that.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Urgent: SAX parser bean is not working in JSP page
Hi All,
I have created a bean "ReadAtts" and included into a jsp file using
"useBean", It is not working. I tried all possibilities. But Failed Plz Help me.
Below are the details:
Java Bean: ReadAtts.java
package sax;
import java.io.*;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.util.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.ParserConfigurationException;
public class ReadAtts extends DefaultHandler implements java.io.Serializable
private Vector attNames = new Vector(); //Stores all the att names from the XML
private Vector attValues = new Vector();
private Vector att = new Vector();
private Locator locator;
private static String start="",end="",QueryString="",QString1="",QString2="";
private static boolean start_collecting=false;
public ReadAtts()
public Vector parse(String filename,String xpath) throws Exception
QueryString=xpath;
StringTokenizer QueryString_ST = new StringTokenizer(QueryString,"/");
int stLen = QueryString_ST.countTokens();
while(QueryString_ST.hasMoreTokens())
if((QueryString_ST.countTokens())>1)
QString1 = QueryString_ST.nextToken();
else if((QueryString_ST.countTokens())>0)
QString2 = QueryString_ST.nextToken();
SAXParserFactory spf =
SAXParserFactory.newInstance();
spf.setValidating(false);
SAXParser saxParser = spf.newSAXParser();
// create an XML reader
XMLReader reader = saxParser.getXMLReader();
FileReader file = new FileReader(filename);
// set handler
reader.setContentHandler(this);
// call parse on an input source
reader.parse(new InputSource(file));
att.add("This is now added");
//return attNames;
return att;
public void setDocumentLocator(Locator locator)
this.locator = locator;
public void startDocument() { }
public void endDocument() { }
public void startPrefixMapping(String prefix, String uri) { }
public void endPrefixMapping(String prefix) { }
/** The opening tag of an element. */
public void startElement(String namespaceURI, String localName,String qName, Attributes atts)
start=localName;
if(start.equals(QString2))
start_collecting=true; //start collecting nodes
if(start_collecting)
if((atts.getLength())>0)
for(int i=0;i<=(atts.getLength()-1);i++)
attNames.add((String)atts.getLocalName(i));
attValues.add((String)atts.getValue(i));
/** The closing tag of an element. */
public void endElement(String namespaceURI, String localName, String qName)
end = localName;
if(end.equals(QString2))
start_collecting=false; //stop colelcting nodes
/** Character data. */
public void characters(char[] ch, int start, int length) { }
/** Ignorable whitespace character data. */
public void ignorableWhitespace(char[] ch, int start, int length){ }
/** Processing Instruction */
public void processingInstruction(String target, String data) { }
/** A skipped entity. */
public void skippedEntity(String name) { }
public static void main(String[] args)
String fname=args[0];
String Xpath=args[1];
System.out.println("\n from main() "+(new ReadAtts().parse(fname,Xpath)));
//System.out.println("\n from main() "+new ReadAtts().attNames());
//System.out.println("\n from main() "+new ReadAtts().attValues());
JSP File:
<%@ page import="sax.*,java.io.*,java.util.*,java.lang.*,java.text.*;" %>
<jsp:useBean id="p" class="sax.ReadAtts"/>
Data after Parsing is.....
<%=p.parse"E:/Log.xml","/acq/service/metrics/system/stackUsage")%>
Expected Output:
The jsp file should print all the vector objects from the "ReadAtts" bean
Actual Output:
Data after Parsing.......[]
Thanks for your time.....
Newton
Bangalore. INDIAthe problem is not because of java code insdie jsp page
I have removed all things but the form and it is still not working
here is the modified code:
<!-- add news-->
<%
if(request.getParameter("addBTN") != null){
out.print("addBTN");
%>
<!-- end of add news-->
<form action="" method="post" enctype="multipart/form-data" name="upform" >
<table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
</tr>
<tr>
<td width="87%" align="right"><label>
<input name="title" type="text" class="rightText" id="title">
</label></td>
<td width="13%" align="right">9FH'F 'D.(1</td>
</tr>
<tr>
<td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
</textarea></td>
<td align="right">*A'5JD 'D.(1</td>
</tr>
<tr>
<td align="right"><label>
<input type="file" name="filename" id="filename">
</label></td>
<td align="right">5H1)</td>
</tr>
<tr>
<td align="right"><label>
<input name="addBTN" type="submit" class="btn" id="addBTN" value=" '6'A) .(1 ">
</label></td>
<td align="right"> </td>
</tr>
</table>
</form>
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple",
directionality : "rtl"
</script>
<!--end of TinyMCE --> -
How to format this table in jsp page?
I have a table in database and there are four data field in it.They are "id","name","email","registetime".
In javabean,I add all this data to a vector:" ResultSet rs;
while(rs.next()){
vec.add(rs.getString("id");
vec.add(rs.getString("name");
vec.add(rs.getString("email");
vec.add(rs.getString("registetime");} ";
I use a Iterator to read all the data to jsp page:"
iter=vec.iterator();
while(iter.hasNext()){
int i=0;
%>
<table border="1" bordercolor="#FF6699" bgcolor="#CCCC99">
<%
if(i==0|i%8==0){
out.println("<td><tr>");
%>
<%=iter.next()%>
</td>
<%
if(i%8==0)
out.println("</tr></td>");
i++;
%></table>
I use a variable i for change range.I want to output a '\n' after output 4 data.But now the data in IE is this:
1
lyo
[email protected]
2003-6
2
Yashnoo
[email protected]
2003-7
It not that I want to get.I means I want to get data like this:
1 lyo [email protected] 2003-6
2 Yashnoo [email protected] 2003-7
How can I do? :(Anyone has idea?But I change it to this:
<body>
<table border="1" bordercolor="#FF6699" bgcolor="#CCCC99">
<%
Iterator iter=null;
ResultSet rs=null;
Vector vec=new Vector();
vec=lyo.addData(rs,vec);
iter=vec.iterator();
try{
while(iter.hasNext()){
int i=0;
%>
<%
if(i%8==0){
out.print("<tr>");
out.print("<td>");
%>
<%=iter.next()%>
<%
out.print("</td>");
if(i%8==0){
out.print("</tr>");
i++;
%></table>
<%
}catch(Exception e){
out.println(e.toString());
%>
It can't help? Why? -
How to access a static method inside the JSP page
Here i had wrote the code in java to access databases , i had include the class path to all the class files.
my problem is when i click the register.jsp page, it will pose eror as null pointer exception i've put my code in this section as follows
memberchecking.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,businessclasses.*,businessobjects.*,projectutils.DateUtilities.*,java.util.*" errorPage="" %>
<html>
<head>
<title>Checking Member's Registration Details...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
String loginId = request.getParameter("loginId");
String resourcePassword = request.getParameter("resourcePassword");
String confirmPassword = request.getParameter("confirmPassword");
String resourceStatus=request.getParameter("resourceStatus");
String nameTitle = request.getParameter("nameTitle");
String jobTitle = request.getParameter("jobTitle");
String firstName = request.getParameter("firstName");
String middleName = request.getParameter("middleName");
String lastName = request.getParameter("lastName");
String displayName = request.getParameter("displayName");
String resourceInitials = request.getParameter("resourceIniitials");
String countryCode = request.getParameter("countryCode");
String resourceLanguage = request.getParameter("resourceLanguage");
//String resourceCurrency = request.getParameter("resourceCurrency");
String resourceEmail2 = request.getParameter("resourceEmail2");
String birthMonth = request.getParameter("birthMonth");
String birthDay = request.getParameter("birthDay");
String birthYear = request.getParameter("birthYear");
String resourceGender = request.getParameter("resourceGender");
String martialStatus = request.getParameter("martialStatus");
String resourceOccupation = request.getParameter("resourceOccupation");
String webPage = request.getParameter("webPage");
String homePhone = request.getParameter("homePhone");
String homePhone2 = request.getParameter("homephone2");
String homeFax = request.getParameter("homepFax");
String phoneOffice = request.getParameter("phoneOffice");
String phoneOffice2 = request.getParameter("phoneOffice2");
String officeFax = request.getParameter("officeFax");
String resourcePager = request.getParameter("resourcePager");
String resourceMobile = request.getParameter("resourceMobile");
String resourceType=request.getParameter("resourceType");
String resourceName = firstName + " " + middleName + " " + lastName;
//java.util.Date resourceBirthDate = (String)birthMonth + "/" + birthDay + "/" + birthYear;
session.setAttribute("Name",resourceName);
session.setAttribute("UserId",loginId);
out.println("name==========="+resourceName);
//check whether the input data is valid for insert
//input validation code goes here.....
ResourceBC aResourceBC=new ResourceBC();
//marshall the resource
ResourceBO resource=new ResourceBO();
String e1 = (String)resource.getEmail();
String e2 = (String)resource.getEmail2();
if(loginId != e1 && resourceEmail2 != e2 ) {
resource.setStatus( "L");
resource.setId(5);
resource.setCountryCode(countryCode);
// resource.setResourceTypeCode(resourceType);
// resource.setResourceParent(rs.getLong(6));
// resource.setHKey(rs.getLong(7));
resource.setName(resourceName);
resource.setDisplayName(displayName);
resource.setLogonPassword(resourcePassword);
resource.setNameTitle(nameTitle);
resource.setJobTitle(jobTitle);
resource.setEmail(loginId);
resource.setEmail2(resourceEmail2);
// resource.setPasswordUpdateDate(rs.getDate(14));
// resource.setPasswordExpireDate(rs.getDate(15));
// resource.setAccessCode(rs.getString(16));
// resource.setLogonUnSuccessTries(0);
resource.setWebPage(webPage);
resource.setPhoneOffice(phoneOffice);
resource.setPhoneOffice2(phoneOffice2);
resource.setPhoneOfficeFax(officeFax);
resource.setPhoneHome(homePhone);
resource.setPhoneHome2(homePhone2);
resource.setPhoneHomeFax(homeFax);
resource.setMobile(resourceMobile);
resource.setPager(resourcePager);
resource.setStatus(resourceStatus);
resource.setGender(resourceGender);
// resource.setBirthDate(resourceBirthDate);
resource.setMartialStatus(martialStatus);
resource.setLanguage(resourceLanguage);
// resource.setCurrency(resourceCurrency);
// resource.setPhoto(photo);
resource.setInitials(resourceInitials);
// resource.setCreatedBy(1);
// resource.setCreatedDate(rs.getDate(36));
// resource.setUpdatedBy(rs.getLong(37));
// resource.setUpdatedDate(rs.getDate(38));
resource.setFirstName(firstName);
resource.setLastName(lastName);
resource.setMiddleName(middleName);
//resource.setCreatedDate(new java.sql.Date());
int rowsAdded=aResourceBC.resourceAdd(resource);
out.println("rowsAdded= "+rowsAdded);
//add message for success or failure to add resource
String msg="";
if(rowsAdded == -1){
msg="<font color=red>The ResourceName already exists .Try another</font>";
session.setAttribute("message",msg);
response.sendRedirect(response.encodeRedirectURL("memberregister.jsp"));
else if(rowsAdded > 0){
msg="<font color=green>Resource Added successfully..........</font>";
session.setAttribute("message",msg);
%>
<jsp:forward page="memberlist.jsp">
<jsp:param name="message" value="<%=msg%>"/>
</jsp:forward>
<%}
%>
</body>
</html>
ResourceBC.java
package businessclasses;
import java.sql.*;
import businessobjects.ResourceBO;
import java.util.*;
import dbutilities.DBManager;
public class ResourceBC
public Vector resourceList() throws Exception{
Vector resourceList=new Vector();
String listSQL="";
StringBuffer listSQLBuffer=new StringBuffer();
listSQLBuffer.append("SELECT ");
listSQLBuffer.append("RES_ID,");
listSQLBuffer.append("RES_NAME,");
listSQLBuffer.append("CNTRY_CODE,");
listSQLBuffer.append("RES_LOGON_PASSWORD,");
listSQLBuffer.append("RESTYPE_CODE,");
listSQLBuffer.append("RES_PARENT,");
listSQLBuffer.append("RES_HKEY,");
listSQLBuffer.append("RES_DISPLAY_NAME,");
listSQLBuffer.append("RES_NAME_TITLE,");
listSQLBuffer.append("RES_JOB_TITLE,");
listSQLBuffer.append("RES_EMAIL,");
listSQLBuffer.append("RES_EMAIL2,");
listSQLBuffer.append("RES_PASSWORD_ACTION,");
listSQLBuffer.append("RES_PASSWORD_UPDATE_DATE,");
listSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE,");
listSQLBuffer.append("RES_ACCESS_CODE,");
listSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES,");
listSQLBuffer.append("RES_WEB_PAGE,");
listSQLBuffer.append("RES_PHONE_OFFICE,");
listSQLBuffer.append("RES_PHONE_OFFICE2,");
listSQLBuffer.append("RES_PHONE_OFFICE_FAX,");
listSQLBuffer.append("RES_PHONE_HOME,");
listSQLBuffer.append("RES_PHONE_HOME2,");
listSQLBuffer.append("RES_PHONE_HOME_FAX,");
listSQLBuffer.append("RES_MOBILE,");
listSQLBuffer.append("RES_PAGER,");
listSQLBuffer.append("RES_STATUS,");
listSQLBuffer.append("RES_GENDER,");
listSQLBuffer.append("RES_BIRTH_DATE,");
listSQLBuffer.append("RES_MARTIAL_STATUS,");
listSQLBuffer.append("RES_LANGUAGE,");
listSQLBuffer.append("RES_CURRENCY,");
listSQLBuffer.append("RES_PHOTO,");
listSQLBuffer.append("RES_CREATED_BY,");
listSQLBuffer.append("RES_NAME_INITIALS,");
listSQLBuffer.append("RES_CREATED_DATE,");
listSQLBuffer.append("RES_UPDATED_BY");
listSQLBuffer.append("RES_UPDATED_DATE,");
listSQLBuffer.append("RES_NAME_FIRST,");
listSQLBuffer.append("RES_NAME_LAST,");
listSQLBuffer.append("RES_NAME_MIDDLE");
listSQLBuffer.append(" FROM T_RESOURCES ");
listSQL=listSQLBuffer.toString();
System.out.println("listSQL---"+listSQL);
DBManager dbManager=new DBManager();
Connection con =dbManager.getConnection();
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(listSQL);
ResourceBO resource=null;
while(rs.next()){
resource=new ResourceBO();
resource.setId(rs.getLong(1));
resource.setName(rs.getString(2));
resource.setCountryCode(rs.getString(3));
resource.setLogonPassword(rs.getString(4));
resource.setResourceTypeCode(rs.getLong(5));
resource.setResourceParent(rs.getLong(6));
resource.setHKey(rs.getLong(7));
resource.setDisplayName(rs.getString(8));
resource.setNameTitle(rs.getString(9));
resource.setJobTitle(rs.getString(10));
resource.setEmail(rs.getString(11));
resource.setEmail2(rs.getString(12));
resource.setPasswordAction(rs.getString(13));
resource.setPasswordUpdateDate(rs.getDate(14));
resource.setPasswordExpireDate(rs.getDate(15));
resource.setAccessCode(rs.getString(16));
resource.setLogonUnSuccessTries(rs.getLong(17));
resource.setWebPage(rs.getString(18));
resource.setPhoneOffice(rs.getString(19));
resource.setPhoneOffice2(rs.getString(20));
resource.setPhoneOfficeFax(rs.getString(21));
resource.setPhoneHome(rs.getString(22));
resource.setPhoneHome2(rs.getString(23));
resource.setPhoneHomeFax(rs.getString(24));
resource.setMobile(rs.getString(25));
resource.setPager(rs.getString(26));
resource.setStatus(rs.getString(27));
resource.setGender(rs.getString(28));
resource.setBirthDate(rs.getDate(29));
resource.setMartialStatus(rs.getString(30));
resource.setLanguage(rs.getString(31));
resource.setCurrency(rs.getString(32));
resource.setPhoto(rs.getString(33));
resource.setCreatedBy(rs.getLong(34));
resource.setInitials(rs.getString(35));
resource.setCreatedDate(rs.getDate(36));
resource.setUpdatedBy(rs.getLong(37));
resource.setUpdatedDate(rs.getDate(38));
resource.setFirstName(rs.getString(39));
resource.setLastName(rs.getString(40));
resource.setMiddleName(rs.getString(41));
resourceList.add(resource);
con.close();
con=null;
return resourceList;
//Method to insert the values into the database
public int resourceAdd(ResourceBO resource){
System.out.println("in resourceAdd method ");
//check for duplicate record in the table
String checkDuplicationSQL="SELECT RES_ID FROM T_RESOURCES WHERE RES_ID='"+resource.getId()+"'";
DBManager dbManager=new DBManager();//.getInstance();
boolean hasDuplicateRecord=dbManager.hasDuplicateRecord(checkDuplicationSQL);
int rowsAdded=0;
//insert the record
//hasDuplicateRecord=false;
if(!hasDuplicateRecord){
//get the next resource id for insertion
long nextID=dbManager.getNextIDForColumnAndTable("RES_ID","T_RESOURCES");
System.out.println("nextID================== "+nextID);
StringBuffer fieldsbuffer=new StringBuffer();
fieldsbuffer.append("INSERT INTO T_RESOURCES (");
fieldsbuffer.append("RES_ID,");
fieldsbuffer.append("RES_NAME,");
fieldsbuffer.append("CNTRY_CODE,");
fieldsbuffer.append("RES_LOGON_PASSWORD,");
fieldsbuffer.append("RESTYPE_CODE,");
fieldsbuffer.append("RES_PARENT,");
fieldsbuffer.append("RES_HKEY,");
fieldsbuffer.append("RES_DISPLAY_NAME,");
fieldsbuffer.append("RES_NAME_TITLE,");
fieldsbuffer.append("RES_JOB_TITLE,");
fieldsbuffer.append("RES_EMAIL,");
fieldsbuffer.append("RES_EMAIL2,");
fieldsbuffer.append("RES_PASSWORD_ACTION,");
fieldsbuffer.append("RES_PASSWORD_UPDATE_DATE,");
fieldsbuffer.append("RES_PASSWORD_EXPIRE_DATE,");
fieldsbuffer.append("RES_ACCESS_CODE,");
fieldsbuffer.append("RES_LOGON_UNSUCCESS_TRIES,");
fieldsbuffer.append("RES_WEB_PAGE,");
fieldsbuffer.append("RES_PHONE_OFFICE,");
fieldsbuffer.append("RES_PHONE_OFFICE2,");
fieldsbuffer.append("RES_PHONE_OFFICE_FAX,");
fieldsbuffer.append("RES_PHONE_HOME,");
fieldsbuffer.append("RES_PHONE_HOME2,");
fieldsbuffer.append("RES_PHONE_HOME_FAX,");
fieldsbuffer.append("RES_MOBILE,");
fieldsbuffer.append("RES_PAGER,");
fieldsbuffer.append("RES_STATUS,");
fieldsbuffer.append("RES_GENDER,");
fieldsbuffer.append("RES_BIRTH_DATE,");
fieldsbuffer.append("RES_MARTIAL_STATUS,");
fieldsbuffer.append("RES_LANGUAGE,");
fieldsbuffer.append("RES_CURRENCY,");
fieldsbuffer.append("RES_PHOTO,");
/* fieldBuffer.append("RES_CREATED_BY,");
fieldBuffer.append("RES_NAME_INITIALS,");
fieldBuffer.append("RES_CREATED_DATE,");
fieldBuffer.append("RES_UPDATED_BY");
fieldBuffer.append("RES_UPDATED_DATE,");
fieldBuffer.append("RES_NAME_FIRST,");
fieldBuffer.append("RES_NAME_LAST,");
fieldBuffer.append("RES_NAME_MIDDLE"); */
StringBuffer valuesBuffer=new StringBuffer(" VALUES(");
valuesBuffer.append(nextID+",");
valuesBuffer.append("'"+resource.getName()+",");
valuesBuffer.append("'"+resource.getCountryCode()+",");
valuesBuffer.append("'"+resource.getLogonPassword()+"',");
valuesBuffer.append("'"+resource.getResourceTypeCode()+",");
valuesBuffer.append("'"+resource.getResourceParent()+",");
valuesBuffer.append("'"+resource.getHKey()+",");
valuesBuffer.append("'"+resource.getDisplayName()+",");
valuesBuffer.append("'"+resource.getNameTitle()+",");
valuesBuffer.append("'"+resource.getJobTitle()+",");
valuesBuffer.append("'"+resource.getEmail()+"',");
valuesBuffer.append("'"+resource.getEmail2()+"',");
valuesBuffer.append("'"+resource.getPasswordAction()+",");
valuesBuffer.append("'"+resource.getPasswordUpdateDate()+",");
valuesBuffer.append("'"+resource.getPasswordExpireDate()+",");
valuesBuffer.append("'"+resource.getAccessCode()+",");
valuesBuffer.append("'"+resource.getLogonUnsuccessTries()+",");
valuesBuffer.append("'"+resource.getWebPage()+"',");
valuesBuffer.append("'"+resource.getPhoneOffice()+"',");
valuesBuffer.append("'"+resource.getPhoneOffice2()+"',");
valuesBuffer.append("'"+resource.getPhoneOfficeFax()+"',");
valuesBuffer.append("'"+resource.getPhoneHome()+"',");
valuesBuffer.append("'"+resource.getPhoneHome2()+"',");
valuesBuffer.append("'"+resource.getPhoneHomeFax()+"',");
valuesBuffer.append("'"+resource.getMobile()+"',");
valuesBuffer.append("'"+resource.getPager()+"',");
valuesBuffer.append("'"+resource.getStatus()+"',");
valuesBuffer.append("'"+resource.getGender()+"',");
valuesBuffer.append("'"+resource.getBirthDate()+"',");
valuesBuffer.append("'"+resource.getMartialStatus()+"',");
valuesBuffer.append("'"+resource.getLanguage()+"',");
valuesBuffer.append("'"+resource.getCurrency()+"',");
valuesBuffer.append("'"+resource.getPhoto()+"',");
valuesBuffer.append("'"+resource.getCreatedBy()+"',");
valuesBuffer.append("'"+resource.getInitials()+"',");
valuesBuffer.append("'"+resource.getCreatedDate()+"',");
valuesBuffer.append("'"+resource.getUpdatedBy()+"',");
valuesBuffer.append("'"+resource.getUpdatedDate()+"',");
valuesBuffer.append("'"+resource.getFirstName()+"',");
valuesBuffer.append("'"+resource.getLastName()+"',");
valuesBuffer.append("'"+resource.getMiddleName()+"')");
String insertSQL=fieldsbuffer.toString()+valuesBuffer.toString();
System.out.println("insertSQL="+insertSQL);
rowsAdded=dbManager.executeSQL(insertSQL);
System.out.println("rowsAdded= "+rowsAdded+"hasDuplicateRecord "+hasDuplicateRecord);
}//end if
else{
//throw new Exception("Has a duplicate Record");
return -1;
return rowsAdded;
public int resourceUpdate(ResourceBO resource){
int rowsUpdated=0;
/* String orgCodeStr=null;
if(resource.getOrgCode()==0){
orgCodeStr="NULL";
}else{
orgCodeStr=""+resource.getOrgCode();
StringBuffer updateSQLBuffer=new StringBuffer();
updateSQLBuffer.append("UPDATE T_RESOURCES SET ");
updateSQLBuffer.append("RES_NAME='"+resource.getName()+"',");
updateSQLBuffer.append("CNTRY_CODE='"+resource.getCountryCode()+"',");
updateSQLBuffer.append("RES_LOGON_PASSWORD='"+resource.getLogonPassword()+"',");
updateSQLBuffer.append("RESTYPE_CODE="+resource.getResourceTypeCode()+",");
updateSQLBuffer.append("RES_PARENT="+resource.getResourceParent()+",");
updateSQLBuffer.append("RES_HKEY="+resource.getHKey()+",");
updateSQLBuffer.append("RES_DISPLAY_NAME="+resource.getDisplayName()+",");
updateSQLBuffer.append("RES_NAME_TITLE="+resource.getNameTitle()+",");
updateSQLBuffer.append("RES_JOB_TITLE="+resource.getJobTitle()+",");
updateSQLBuffer.append("RES_EMAIL='"+resource.getEmail()+"',");
updateSQLBuffer.append("RES_EMAIL2='"+resource.getEmail2()+"',");
updateSQLBuffer.append("RES_PASSWORD_ACTION="+resource.getPasswordAction()+",");
updateSQLBuffer.append("RES_PASSWORD_UPDATE_DATE="+resource.getPasswordUpdateDate()+",");
updateSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE="+resource.getPasswordExpireDate()+",");
updateSQLBuffer.append("RES_ACCESS_CODE="+resource.getAccessCode()+",");
updateSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES="+resource.getLogonUnsuccessTries()+",");
updateSQLBuffer.append("RES_WEB_PAGE='"+resource.getWebPage()+"',");
updateSQLBuffer.append("RES_PHONE_OFFICE='"+resource.getPhoneOffice()+"',");
updateSQLBuffer.append("RES_PHONE_OFFICE2='"+resource.getPhoneOffice2()+"',");
updateSQLBuffer.append("RES_PHONE_OFFICE_FAX='"+resource.getPhoneOfficeFax()+"',");
updateSQLBuffer.append("RES_PHONE_HOME='"+resource.getPhoneHome()+"',");
updateSQLBuffer.append("RES_PHONE_HOME2='"+resource.getPhoneHome2()+"',");
updateSQLBuffer.append("RES_PHONE_HOME_FAX='"+resource.getPhoneHomeFax()+"',");
updateSQLBuffer.append("RES_MOBILE='"+resource.getMobile()+"',");
updateSQLBuffer.append("RES_PAGER='"+resource.getPager()+"',");
updateSQLBuffer.append("RES_STATUS='"+resource.getStatus()+"',");
updateSQLBuffer.append("RES_GENDER='"+resource.getGender()+"',");
updateSQLBuffer.append("RES_BIRTH_DATE='"+resource.getBirthDate()+"',");
updateSQLBuffer.append("RES_MARTIAL_STATUS='"+resource.getMartialStatus()+"',");
updateSQLBuffer.append("RES_LANGUAGE='"+resource.getLanguage()+"',");
updateSQLBuffer.append("RES_CURRENCY='"+resource.getCurrency()+"',");
updateSQLBuffer.append("RES_PHOTO='"+resource.getPhoto()+"',");
updateSQLBuffer.append("RES_NAME_INITIALS='"+resource.getInitials()+"',");
updateSQLBuffer.append("RES_NAME_FIRST='"+resource.getFirstName()+"',");
updateSQLBuffer.append("RES_NAME_LAST='"+resource.getLastName()+"',");
updateSQLBuffer.append("RES_NAME_MIDDLE='"+resource.getMiddleName()+"'");
updateSQLBuffer.append("WHERE RES_ID="+resource.getId());
String updateSQL=updateSQLBuffer.toString();
//String updateSQL="UPDATE T_RESOURCES SET CLIENT_NAME='"+resource.getName()+"',CLIENT_STATUS='"+resource.getStatus()+"',CLIENT_EMAIL_PRIMARY='"+resource.getEmailPrimary()+"',CLIENT_EMAIL_ALTERNATIVE='"+resource.getEmailAlternate()+"',CLIENT_CURRENCY_SYMBOL='"+resource.getCurrencySymbol()+"',CLIENT_CURRENCY_DIGITS="+resource.getCurrencyDigits()+",CLIENT_DIRECTORY_DOCUMENT='"+resource.getDirectoryDocument()+"',CLIENT_DIRECTORY_TEMPLATE='"+resource.getDirectoryTemplate()+"',CLIENT_STORAGE_QUOTA="+resource.getStorageQuota()+",CLIENT_KEY='"+resource.getKey()+"' WHERE CLIENT_ID="+resource.getId();
System.out.println("updateSQL---"+updateSQL);
DBManager dbManager=new DBManager();
rowsUpdated=dbManager.executeSQL(updateSQL);
return rowsUpdated;
public int resourceDelete(long resourceId){
int rowsDeleted=0;
DBManager dbManager=new DBManager();
String deleteSQL="DELETE FROM T_RESOURCES WHERE RES_ID="+resourceId;
System.out.println("deleteSQL==="+deleteSQL);
rowsDeleted=dbManager.executeSQL(deleteSQL);
System.out.println("rowsDeleted= "+rowsDeleted);
return rowsDeleted;
public ResourceBO getResourceById(long resourceId)throws Exception{
StringBuffer selectSQLBuffer=new StringBuffer();
selectSQLBuffer.append("SELECT ");
selectSQLBuffer.append("RES_ID,");
selectSQLBuffer.append("RES_NAME,");
selectSQLBuffer.append("CNTRY_CODE,");
selectSQLBuffer.append("RES_LOGON_PASSWORD,");
selectSQLBuffer.append("RESTYPE_CODE,");
selectSQLBuffer.append("RES_PARENT,");
selectSQLBuffer.append("RES_HKEY,");
selectSQLBuffer.append("RES_DISPLAY_NAME,");
selectSQLBuffer.append("RES_NAME_TITLE,");
selectSQLBuffer.append("RES_JOB_TITLE,");
selectSQLBuffer.append("RES_EMAIL,");
selectSQLBuffer.append("RES_EMAIL2,");
selectSQLBuffer.append("RES_PASSWORD_ACTION,");
selectSQLBuffer.append("RES_PASSWORD_UPDATE_DATE,");
selectSQLBuffer.append("RES_PASSWORD_EXPIRE_DATE,");
selectSQLBuffer.append("RES_ACCESS_CODE,");
selectSQLBuffer.append("RES_LOGON_UNSUCCESS_TRIES,");
selectSQLBuffer.append("RES_WEB_PAGE,");
selectSQLBuffer.append("RES_PHONE_OFFICE,");
selectSQLBuffer.append("RES_PHONE_OFFICE2,");
selectSQLBuffer.append("RES_PHONE_OFFICE_FAX,");
selectSQLBuffer.append("RES_PHONE_HOME,");
selectSQLBuffer.append("RES_PHONE_HOME2,");
selectSQLBuffer.append("RES_PHONE_HOME_FAX,");
selectSQLBuffer.append("RES_MOBILE,");
selectSQLBuffer.append("RES_PAGER,");
selectSQLBuffer.append("RES_STATUS,");
selectSQLBuffer.append("RES_GENDER,");
selectSQLBuffer.append("RES_BIRTH_DATE,");
selectSQLBuffer.append("RES_MARTIAL_STATUS,");
selectSQLBuffer.append("RES_LANGUAGE,");
selectSQLBuffer.append("RES_CURRENCY,");
selectSQLBuffer.append("RES_PHOTO,");
selectSQLBuffer.append("RES_CREATED_BY,");
selectSQLBuffer.append("RES_NAME_INITIALS,");
selectSQLBuffer.append("RES_CREATED_DATE,");
selectSQLBuffer.append("RES_UPDATED_BY");
selectSQLBuffer.append("RES_UPDATED_DATE,");
selectSQLBuffer.append("RES_NAME_FIRST,");
selectSQLBuffer.append("RES_NAME_LAST,");
selectSQLBuffer.append("RES_NAME_MIDDLE");
selectSQLBuffer.append(" FROM T_RESOURCES WHERE RES_ID="+resourceId);
String fetchSQL=selectSQLBuffer.toString();
System.out.println("fetchSQL---"+fetchSQL);
DBManager dbManager=new DBManager();
Connection con =dbManager.getConnection();
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(fetchSQL);
ResourceBO resource=new ResourceBO();
while(rs.next()){
resource.setId(rs.getLong(1));
resource.setName(rs.getString(2));
resource.setCountryCode(rs.getString(3));
resource.setLogonPassword(rs.getString(4));
resource.setResourceTypeCode(rs.getLong(5));
resource.setResourceParent(rs.getLong(6));
resource.setHKey(rs.getLong(7));
resource.setDisplayName(rs.getString(8));
resource.setNameTitle(rs.getString(9));
resource.setJobTitle(rs.getString(10));
resource.setEmail(rs.getString(11));
resource.setEmail2(rs.getString(12));
resource.setPasswordAction(rs.getString(13));
resource.setPasswordUpdateDate(rs.getDate(14));
resource.setPasswordExpireDate(rs.getDate(15));
resource.setAccessCode(rs.getString(16));
resource.setLogonUnSuccessTries(rs.getLong(17));
resource.setWebPage(rs.getString(18));
resource.setPhoneOffice(rs.getString(19));
resource.setPhoneOffice2(rs.getString(20));
resource.setPhoneOfficeFax(rs.getString(21));
resource.setPhoneHome(rs.getString(22));
resource.setPhoneHome2(rs.getString(23));
resource.setPhoneHomeFax(rs.getString(24));
resource.setMobile(rs.getString(25));
resource.setPager(rs.getString(26));
resource.setStatus(rs.getString(27));
resource.setGender(rs.getString(28));
resource.setBirthDate(rs.getDate(29));
resource.setMartialStatus(rs.getString(30));
resource.setLanguage(rs.getString(31));
resource.setCurrency(rs.getString(32));
resource.setPhoto(rs.getString(33));
resource.setCreatedBy(rs.getLong(34));
resource.setInitials(rs.getString(35));
resource.setCreatedDate(rs.getDate(36));
resource.setUpdatedBy(rs.getLong(37));
resource.setUpdatedDate(rs.getDate(38));
resource.setFirstName(rs.getString(39));
resource.setLastName(rs.getString(40));
resource.setMiddleName(rs.getString(41));
con.close();
con=null;
return resource;
}//end of class
plz help me to solve this problem....
rajkumarThe JSP wil be converted into a java file and then compiled into a class. If you are using tomcat, the java file will be somewhere in the work folder of your tomcat installation. Find the java file and check the line that is reported in the exception to see where the null-pointer is coming from.
-
How to add or remove data from one table to another in � jsp page
I have two tables on my jsp page.
On the fist table feed by a data base, u have in the first column radiobutton
second colum data
third columm data
on the second table feed by the data of the first table, u have in the first
columm checkbox
second colum data
this column data
u have two link, one link to add and another to remove
1 when u click one of the radiobutton of the fist table following by the click of the link add, u add the line into the second table.
2 when u click on one or two checkboxes of the second table following by a click on the link remove, u remove the line or lines checked.
Did somebody could send to me en example of code and give to me solution on way to make it. thank u.rather than sending you the whole code, i would like
to see your code first, how far you implemented the
code ? and where are you getting problem, asking the
code like this is not a professional.
All the Best !******************************************************************************************************************************
that's what i have implements. U have a bean witch picked data in that the data base, and catch properties .
i describe to u how work the page.
when u chose or selected TypeDetoyer, it present to u the first table with all the toyer contains in the typeDeToyer, and presents the second table empty.
Secondly, u click a radio button to select � toyer of typeDeToyer and by clicking to the link ada, u feed the second table with the toyer selected.
the seconde table is fill with a checkbox.
inverse, when u check a check box or many of the second table and clicking on the link remove, u remove the selected lines.
the aim of all of this is to save in the data base
the second table, after saving the page is redirect to the modifying form.
I am waiting for ur answer.
Coul u send to me how u implements the part beetween the two tables
Thank s
<%@ page language="java" import="java.util.*"%>
<jsp:useBean id="nsimalenBean" scope="session" class="nsimalen.NsimalenBean" />
<jsp:useBean id="toyerBean" scope="session" class="nsimalen.ToyerBean" />
<jsp:useBean id="vectorLstTasks" scope="session" class="java.util.Vector" />
<jsp:useBean id="hashtableToyerSelected" scope="session" class="java.util.Hashtable"/>
<jsp:useBean id="hashtableRegimeFiscalToyers" scope="session" class="java.util.Hashtable"/>
<%
//nsimalen.NsimalenBean nsimalenBean=nsimalenBean();
///vectorLstTasks.removeElementAt(i);
String cVide="";
String typeOperation;
String monCodeNsimalen;
//String monCodeNsimalen=request.getParameter("txtCreateNsimalenFormCode");
String monNomNsimalen;
String maVilleNsimalen;
String monPaysNsimalen;
String monTypeDetoyerSelected;
String codeToyerSelected;
String codeToyerSelectedToAdd;
String codeToyerSelectedToRemove;
String currentlibelleTypeDetoyer=cVide;
String typeAction;
/// d�finition de variable dont les valeurs seront stock�es dans l'objet de session
if(request.getParameter("txtCreateNsimalenFormCode")!=null)
monCodeNsimalen=request.getParameter("txtCreateNsimalenFormCode");
else
monCodeNsimalen=cVide;
if(request.getParameter("txtCreateNsimalenFormNom")!=null)
monNomNsimalen=request.getParameter("txtCreateNsimalenFormNom");
else
monNomNsimalen=cVide;
if(request.getParameter("txtCreateNsimalenFormVille")!=null)
maVilleNsimalen=request.getParameter("txtCreateNsimalenFormVille");
else
maVilleNsimalen=cVide;
if(request.getParameter("selCreateNsimalenFormPays")!=null)
monPaysNsimalen=request.getParameter("selCreateNsimalenFormPays");
else
monPaysNsimalen=cVide;
if(request.getParameter("optCreateNsimalenFormTypeToyer")!=null)
{monTypeDetoyerSelected=request.getParameter("optCreateNsimalenFormTypeToyer");
currentlibelleTypeDetoyer=toyerBean.getLibelleTypedeToyer(monTypeDetoyerSelected);
else
monTypeDetoyerSelected=cVide;
if(request.getParameter("radioCreateNsimalenFormCodeToyers")!=null)
codeToyerSelectedToAdd=request.getParameter("radioCreateNsimalenFormCodeToyers");
else
codeToyerSelectedToAdd=cVide;
if(request.getParameter("radioCreateNsimalenFormCodeToyersRemove")!=null)
codeToyerSelectedToRemove=request.getParameter("radioCreateNsimalenFormCodeToyersRemove");
else
codeToyerSelectedToRemove=cVide;
if(request.getParameter("typeOperation")!=null)
typeOperation=request.getParameter("typeOperation");
else
typeOperation=cVide;
if(request.getParameter("typeAction")!=null)
typeAction=request.getParameter("typeAction");
else
typeAction=cVide;
// Stockage des valeurs dans l'objet
nsimalenBean.setCodePays(monPaysNsimalen);
nsimalenBean.setNomNsimalen(monNomNsimalen);
nsimalenBean.setVilleNsimalen(maVilleNsimalen);
nsimalenBean.setCodeNsimalen(monCodeNsimalen);
nsimalenBean.setDateCreation("12/12/2001");
// if typeOperation=Invalidation
// nsimalenBean.setDatad'invalidation
if(typeAction.equals("Save"))
nsimalenBean.validationCreation();
Vector validationErrors= nsimalenBean.getChampVide();
%>
<body>
<%
if (validationErrors!=null && validationErrors.size()!=0 )
for (int i=0; i<validationErrors.size();i++)
%>
<BR> Champs Invalides : <%=(String)validationErrors.elementAt(i)%>; <BR>
<%
else
if (hashtableToyerSelected!=null && hashtableToyerSelected.size()<=10)
nsimalenBean.insertRowNsimalen();
nsimalenBean.insertRowsToyersAssocieesNsimalen(hashtableToyerSelected);
if (hashtableToyerSelected!=null && hashtableToyerSelected.size()>=0)
%>
<BR> num Toyers max 10 <BR>
<%
if (hashtableToyerSelected!=null && hashtableToyerSelected.size()==0)
%>
<BR> vous devez au moins selectionner une toyer pour un nsimalen <BR>
<%
%>
<form method="post" name="CreateNsimalenForm" action="CreateNsimalen.jsp">
<table cool width="681" height="424" usegridx usegridy showgridx showgridy gridx="16" gridy="16" border="0" cellpadding="0" cellspacing="0">
<tr height="16">
<td width="16" height="423" rowspan="11"></td>
<td width="288" height="16" colspan="3"></td>
<td width="376" height="144" colspan="3" rowspan="5"></td>
<td width="1" height="16"><spacer type="block" width="1" height="16"></td>
</tr>
<tr height="32">
<td width="100" height="32" valign="top" align="left" xpos="16"><label><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b>Code :</b></font></label></td>
<td width="188" height="32" colspan="2" valign="top" align="left" xpos="116"><input type="text" name="txtCreateNsimalenFormCode" size="24" value='<%=nsimalenBean.getCodeNsimalen()%>'></td>
<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
</tr>
<tr height="32">
<td width="100" height="32" valign="top" align="left" xpos="16"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Nom :</b></font></label></td>
<td width="188" height="32" colspan="2" valign="top" align="left" xpos="116"><input type="text" name="txtCreateNsimalenFormNom" size="24" value='<%=nsimalenBean.getNomNsimalen()%>'></td>
<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
</tr>
<input type="hidden" name="typeOperation" size="24" >
<input type="hidden" name="typeAction" size="24" >
<tr height="32">
<td width="100" height="32" valign="top" align="left" xpos="16"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Ville :</b></font></label></td>
<td width="188" height="32" colspan="2" valign="top" align="left" xpos="116"><input type="text" name="txtCreateNsimalenFormVille" size="24" value='<%=nsimalenBean.getNomVille()%>'></td>
<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
</tr>
<tr height="32">
<td width="100" height="32" valign="top" align="left" xpos="16"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Pays : </b></font></label></td>
<td width="188" height="32" colspan="2" valign="top" align="left" xpos="116"><select name="selCreateNsimalenFormPays" size="1">
<option value="" ><b><font size="2" name="optCreateNsimalenFormPays"></font></b></option>
<%
//String cVide="";
Vector nsimalenLst = new Vector();
//strNomNsimalen=request.getParameter("txtSearchFormNom").trim();
nsimalenLst = nsimalenBean.getAllPays();
// Pour savoir la taille du vecteur
if(nsimalenLst!=null && nsimalenLst.size()!=0)
for(int i=0;i< nsimalenLst.size();i++)
Hashtable myrecord = (Hashtable)nsimalenLst.elementAt(i);
String monCodePays ="";
String monLibelle="";
monCodePays =(String)myrecord.get("NNAM_CODE");
monLibelle =(String)myrecord.get("NNAM_LIBELLE");
System.out.println("mon code pays= "+monCodePays+"i="+i+ " mon Libelle Pays="+monLibelle+"nsimalenLst.size() ="+nsimalenLst.size());
%>
<option value='<%=monCodePays%>' <%if(monCodePays.equals(monPaysNsimalen))
out.print("selected");%> ><b><font name="optCreateNsimalenFormPays" size="2"><%=monCodePays%></font></b></option>
<%}
%>
</select></td>
<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
</tr>
<tr height="16">
<td width="664" height="16" colspan="6" valign="top" align="left" xpos="16">
<hr width="644" size="2">
</td>
<td width="1" height="16"><spacer type="block" width="1" height="16"></td>
</tr>
<tr height="32">
<td width="100" height="32" valign="top" align="left" xpos="16"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Type de toyer :</b></font></label></td>
<td width="32" height="32"></td>
<td width="156" height="32" valign="top" align="left" xpos="148"><select name="optCreateNsimalenFormTypeToyer" size="1" onChange="javascript:document.CreateNsimalenForm.submit();">
<option value="" ><b><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"></font></b></option>
<%
//String cVide="";
Vector toyerLst = new Vector();
//strNomNsimalen=request.getParameter("txtSearchFormNom").trim();
toyerLst = toyerBean.getAllTypeDeToyers();
// Pour savoir la taille du vecteur
if(toyerLst!=null && toyerLst.size()!=0)
hashtableRegimeFiscalToyers = new Hashtable();
for(int i=0;i< toyerLst.size();i++)
Hashtable myrecord = (Hashtable)toyerLst.elementAt(i);
String monTypeToyer ="";
String monLibelleToyer="";
monTypeToyer =(String)myrecord.get("TTOY_CODE");
monLibelleToyer =(String)myrecord.get("TTOY_LIBELLE");
// System.out.println("mon code pays= "+monTypeToyer+"i="+i+ " mon Libelle Pays="+monLibelleToyer+"nsimalenLst.size() ="+toyerLst.size());
%>
<option value=<%=monTypeToyer%> <%if(monTypeToyer.equals(monTypeDetoyerSelected))
out.print("selected");%>><b><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><%=monLibelleToyer%></font></b></option>
<%}
}%>
</select></td>
<td width="376" height="32" colspan="3"></td>
<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
</tr>
<tr height="128">
<td width="288" height="128" colspan="3" valign="top" align="left" xpos="16">
<%if (!monTypeDetoyerSelected.equals(cVide))
//String cVide="";
Vector maTypeToyerDetailList = new Vector();
//strNomNsimalen=request.getParameter("txtSearchFormNom").trim();
maTypeToyerDetailList = toyerBean.getToyersDetailsSelected(monTypeDetoyerSelected);
// Pour savoir la taille du vecteur
if(maTypeToyerDetailList!=null && maTypeToyerDetailList.size()!=0)
%>
<table border="1" cellpadding="0" cellspacing="0" width="224" height="75">
<tr height="19">
<td height="19" width="20"></td>
<td height="19" width="46"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Toyer</b></font></td>
<td height="19" width="140"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Libell�</b></font></td>
</tr>
<%
{ hashtableRegimeFiscalToyers= new Hashtable();
System.out.println( " je passe dans le premier for");
for(int i=0;i< maTypeToyerDetailList.size();i++)
Hashtable myRecord = (Hashtable)maTypeToyerDetailList.elementAt(i);
System.out.println( " je passe dans le premier for 1");
String myCodeToyer ="";
String myLibelleToyer="";
String myTypeDeToyerCode="";
myCodeToyer =(String)myRecord.get("TOY_CODE");
myLibelleToyer =(String)myRecord.get("TOY_LIBELLE");
// myTypeDeToyerCode=(String)myRecord.get("TTOY_CODE");
System.out.println( " je passe dans le premier for 2");
Hashtable hashToyerCaracteristique = new Hashtable();
hashToyerCaracteristique.put("TOY_LIBELLE",myLibelleToyer);
hashToyerCaracteristique.put("TTOY_CODE",monTypeDetoyerSelected);
hashToyerCaracteristique.put("TTOY_LIBELLE",currentlibelleTypeDetoyer);
hashtableRegimeFiscalToyers.put(myCodeToyer,hashToyerCaracteristique);
System.out.println( " je passe dans le premier for 3");
%>
<tr height="19">
<td height="19" width="20" align="center" valign="middle"><input type="radio" value='<%=myCodeToyer%>' name="radioCreateNsimalenFormCodeToyers"></td>
<td height="19" width="46"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b><%=myCodeToyer%></b></font></td>
<td width="140" height="19"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b><%=myLibelleToyer%></b></font></td>
</tr>
<%
%>
<%}%>
</table>
</td>
<% System.out.println( " je passe dans le premier for 4_1");
if (hashtableToyerSelected==null)
hashtableToyerSelected = new Hashtable();
System.out.println( " je passe dans le premier for 4_2");
if(hashtableToyerSelected!=null)
System.out.println( " je passe dans le premier for 4_3");
%>
<td width="376" height="128" colspan="3" valign="top" align="left" xpos="304">
<table border="1" cellpadding="0" cellspacing="0" width="355" height="117">
<tr height="38">
<td height="38" width="32"></td>
<td width="47" height="38"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Code</b></font></td>
<td height="38" width="112"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Type de toyer</b></font></td>
<td height="38" width="152"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>valeur par d�faut</b></font></td>
</tr>
<%
System.out.println( " je passe dans le premier for 3");
if(!codeToyerSelectedToAdd.equals(cVide) && typeOperation.equals("add"))
System.out.println( " je passe dans le premier for 3_a");
Hashtable hashToyerCaracteristique = (Hashtable)hashtableRegimeFiscalToyers.get(codeToyerSelectedToAdd);
hashtableToyerSelected.put(codeToyerSelectedToAdd,hashToyerCaracteristique);
System.out.println( " je passe dans le premier for 3_a_fin");
if(!codeToyerSelectedToRemove.equals(cVide) && typeOperation.equals("remove"))
System.out.println( " je passe dans le premier for 3_a");
System.out.println( "remove ");
System.out.println(codeToyerSelectedToRemove);
hashtableToyerSelected.remove(codeToyerSelectedToRemove);
if (hashtableToyerSelected.size()!=0)
for( Enumeration e=hashtableToyerSelected.keys();e.hasMoreElements();)
System.out.println("je rentre dans la boucle");
String codeToyer =(String)e.nextElement();
Hashtable hashToyerCaracteristique = (Hashtable)hashtableToyerSelected.get(codeToyer);
String libelleToyer =(String)hashToyerCaracteristique.get("TOY_LIBELLE");
String libelleTypeToyer =(String)hashToyerCaracteristique.get("TTOY_LIBELLE");
%>
<tr height="19">
<td height="19" width="32" align="center" valign="middle"><input type="checkbox" value="<%=codeToyer%>" name="radioCreateNsimalenFormCodeToyersRemove"></td>
<td width="47" height="19"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b><%=codeToyer %></b></font></td>
<td height="19" width="112"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b><%=libelleTypeToyer %></b></font></td>
<td height="19" width="152"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b><%=libelleToyer %></b></font></td>
</tr>
<%
/* if (!codeToyerSelected.equals(cVide) && hashtableToyerSelected==null)
hashtableToyerSelected = new Hashtable();
if(hashtableToyerSelected!=null)
//insertion du code HTml pour afficher l'entete du tableau
if(operationType.equals("ajout"))
Hahstable toyersdetails = getToyersDetail(IdToyerSelected);
hashtableToyerSelected.put( IdToyerSelected, toyersdetails);
if(operationType.equals("remove"))
hashtableToyerSelected.remove(IdToyerSelected);
// avant d'afficher l'entete verifier qu'il ya des elements dans hashtableToyerSelected (
// hashtableToyerSelected.size!=0
//Affichage de la hashtable
for( Enumeration e=hashtableToyerSelected.keys();e.hasMoreElements;)
String IdToyers =(String)e.nextElement();
Hashtable ToyersDetails = (Hashtable) hashtableToyerSelected.get(IdToyers);
string defaultValue = (String)ToyersDetails.get(defaultValue);
// on fait la mise en page apres avoir recuperer tous les caracteristiques
%>
<!-- <td width="376" height="128" colspan="3" valign="top" align="left" xpos="304">
<table border="1" cellpadding="0" cellspacing="0" width="355" height="117">
<tr height="38">
<td height="38" width="32"></td>
<td width="47" height="38"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Code</b></font></td>
<td height="38" width="112"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>Type de toyer</b></font></td>
<td height="38" width="152"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="3"><b>valeur par défaut</b></font></td>
</tr>
<tr height="19">
<td height="19" width="32" align="center" valign="middle"><input type="checkbox" value="checkboxValue" name="checkboxName"></td>
<td width="47" height="19"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>J</b></font></td>
<td height="19" width="112"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Spécifique</b></font></td>
<td height="19" width="152"><b><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">Nuit</font></b></td>
</tr>
<tr height="19">
<td width="32" align="center" valign="middle" height="19"><input type="checkbox" value="checkboxValue" name="checkboxName"></td>
<td width="47" height="19"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>K</b></font></td>
<td height="19" width="112"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Quantité</b></font></td>
<td height="19" width="152"><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Kilo</b></font></td>
</tr> -->
</table>
</td>
<td width="1" height="128"><spacer type="block" width="1" height="128"></td>
</tr>
<tr height="51">
<td width="100" height="51" valign="top" align="left" xpos="16"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Add</b></font></label></td>
<td width="188" height="51" colspan="2"></td>
<td width="224" height="51" valign="top" align="left" xpos="304"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Remove</b></font></label></td>
<td width="152" height="51" colspan="2"></td>
<td width="1" height="51"><spacer type="block" width="1" height="51"></td>
</tr>
<tr height="13">
<td width="664" height="13" colspan="6" valign="top" align="left" xpos="16">
<hr width="644" size="2">
</td>
<td width="1" height="13"><spacer type="block" width="1" height="13"></td>
</tr>
<tr height="39">
<td width="512" height="39" colspan="4"></td>
<td width="80" height="39" valign="top" align="left" xpos="528"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Save</b></font></label></td>
<td width="72" height="39" valign="top" align="left" xpos="608"><label><font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><b>Fermer</b></font></label></td>
<td width="1" height="39"><spacer type="block" width="1" height="39"></td>
</tr>
<tr height="1" cntrlrow>
<td width="16" height="1"><spacer type="block" width="16" height="1"></td>
<td width="100" height="1"><spacer type="block" width="100" height="1"></td>
<td width="32" height="1"><spacer type="block" width="32" height="1"></td>
<td width="156" height="1"><spacer type="block" width="156" height="1"></td>
<td width="224" height="1"><spacer type="block" width="224" height="1"></td>
<td width="80" height="1"><spacer type="block" width="80" height="1"></td>
<td width="72" height="1"><spacer type="block" width="72" height="1"></td>
<td width="1" height="1"></td>
</tr>
</table>
<p></p>
</form>
</body>
</html> -
ClassCastException in method declaration in JSP page??
i keep getting this ClassCastException in my jsp page. The line that
is apparently the problem is the <%! where the method declaration
starts. I can't seem to figure out why this is happening, can someone
please help? Here is the full code:
java.lang.ClassCastException
at quickfix0itm_0submit__jsp.addUpdate(/epsc/quickfix_itm_submit.jsp:25)
at quickfix0itm_0submit__jsp._jspService(/epsc/quickfix_itm_submit.jsp:165)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:344)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534)
<%
if ( (session.getAttribute("setID") == null ) || ( !session.getAttribute("setID").equals(session.getId()) ))
out.write("You are either not logged in or your session has timed out due to inactivity.<BR>"
+ "Please <a href=\"index.jsp\">return to the login screen</a> and login again<BR><BR>");
else
%>
<%@ page language=java %>
<%@ page import='java.sql.*' %>
<%@ page import='javax.sql.*' %>
<%@ page import='javax.naming.*' %>
<%@ page import='java.io.*' %>
<%@ page import='java.util.Hashtable' %>
<%@ page import='java.util.Vector' %>
<%@ page import='java.util.Enumeration' %>
<%@ page import='java.util.Calendar' %>
<%@ page import='java.util.GregorianCalendar' %>
<%!
private void addUpdate(String[] tmpP, String[] UIDs, String curName, String colName, String lastIdx, Hashtable uid_updates)
if (curName.equals(colName))
for (int c = 0; c < UIDs.length; c++)
Object[] tmp = (Object[])uid_updates.get(UIDs[c]);
Vector colNames = new Vector();
Vector colValues = new Vector();
if (tmp == null)
tmp = new Object[2];
else
colNames = (Vector)tmp[0];
colValues = (Vector)tmp[1];
String updateVal = tmpP[0];
colNames.add(curName);
colValues.add(updateVal);
tmp[0] = colNames;
tmp[1] = colValues;
uid_updates.remove(UIDs[c]);
uid_updates.put(UIDs[c], tmp);
else
int uidIdx = curName.lastIndexOf(lastIdx);
String uidcode = curName.substring(uidIdx + 1);
Object[] tmp = (Object[])uid_updates.get(uidcode);
Vector colNames = new Vector();
Vector colValues = new Vector();
if (tmp == null)
tmp = new Object[2];
else
colNames = (Vector)tmp[0];
colValues = (Vector)tmp[1];
//String[] tmpP = request.getParameterValues(curName);
String updateVal = tmpP[0];
colNames.add(colName);
colValues.add(updateVal);
tmp[0] = colNames;
tmp[1] = colValues;
uid_updates.remove(uidcode);
uid_updates.put(uidcode, tmp);
%>
<%
String ss = "0";
String force_noon = "0";
String qfix_duration = "2";
int qfixd = 2;
String mod_keys = "";
String[] mktmp = request.getParameterValues("mod_keys");
if (mktmp == null)
out.print("Error! Please go back and try again.");
else
mod_keys = mktmp[0];
Hashtable uid_updates = new Hashtable();
String[] UIDs = new String[1];
if (mod_keys.equals("1"))
UIDs = request.getParameterValues("UID");
for (int storeUIDs = 0; storeUIDs < UIDs.length; storeUIDs++)
Vector tmp = new Vector();
uid_updates.put(UIDs[storeUIDs], tmp);
Enumeration cols = request.getParameterNames();
while (cols.hasMoreElements())
String curName = (String)cols.nextElement();
if (curName.indexOf("BusName") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "BusName", "e", uid_updates);
else if (curName.equals("ss"))
String[] asdfadf = request.getParameterValues(curName);
if (asdfadf != null)
ss = "1";
else
ss = "0";
else if (curName.equals("force_noon"))
String[] asdfadf = request.getParameterValues(curName);
force_noon = asdfadf[0];
else if (curName.equals("qfix_duration"))
String[] asdfadf = request.getParameterValues(curName);
qfix_duration = asdfadf[0];
qfixd = Integer.parseInt(qfix_duration);
else if (curName.indexOf("DisplayLine") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DisplayLine", "e", uid_updates);
else if (curName.indexOf("CityName") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "CityName", "e", uid_updates);
else if (curName.indexOf("PAC") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "PAC", "C", uid_updates);
else if (curName.indexOf("ProvDisp") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "ProvDisp", "p", uid_updates);
else if (curName.indexOf("TeleNum") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "TeleNum", "m", uid_updates);
else if (curName.indexOf("ProvCode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "ProvCode", "e", uid_updates);
else if (curName.indexOf("Dircode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "Dircode", "e", uid_updates);
else if (curName.indexOf("Hdgcode") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "Hdgcode", "e", uid_updates);
else if (curName.indexOf("EMail") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EMail", "l", uid_updates);
else if (curName.indexOf("URL") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "URL", "L", uid_updates);
else if (curName.indexOf("DispAd") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DispAd", "d", uid_updates);
else if (curName.indexOf("TOPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "TOPlus", "s", uid_updates);
else if (curName.indexOf("EStore") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EStore", "e", uid_updates);
else if (curName.indexOf("HSLINE_EN") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "HSLINE_EN", "N", uid_updates);
else if (curName.indexOf("HSLINE_FR") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "HSLINE_FR", "R", uid_updates);
else if (curName.indexOf("MtlPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "MtlPlus", "s", uid_updates);
else if (curName.indexOf("CalPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "CalPlus", "s", uid_updates);
else if (curName.indexOf("EdmPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "EdmPlus", "s", uid_updates);
else if (curName.indexOf("VanPlus") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "VanPlus", "s", uid_updates);
else if (curName.indexOf("DEALER_LOCATOR") != -1)
addUpdate(request.getParameterValues(curName), UIDs, curName, "DEALER_LOCATOR", "R", uid_updates);
long curTime = System.currentTimeMillis();
long monthMS = 2629743832L;
long expLength = monthMS * qfixd;
long expTime = curTime + expLength;
java.sql.Date d1 = new java.sql.Date(System.currentTimeMillis());
String Start_Date = d1.toString();
d1 = new java.sql.Date(expTime);
String Expiry_Date = d1.toString();
Context env1 = (Context) new InitialContext().lookup("java:comp/env");
DataSource source1 = (DataSource) env1.lookup("jdbc/epsc");
Connection conn1 = source1.getConnection();
String Pub_ID = "";
try {
Enumeration uidKeys = uid_updates.keys();
while (uidKeys.hasMoreElements())
String Unique_ID = (String)uidKeys.nextElement();
Object[] updateData = (Object[])uid_updates.get(Unique_ID);
Vector colNames = (Vector)updateData[0];
Vector colValues = (Vector)updateData[1];
String selectRecord = "SELECT * from epsc_ypca WHERE Unique_ID='" + Unique_ID + "';";
Statement getRecord = conn1.createStatement();
ResultSet returned = getRecord.executeQuery(selectRecord);
Pub_ID = returned.getString("Pub_ID");
boolean createDelete = false;
String updateString = "";
for (int b = 0; b < colNames.size(); b++)
if (b != 0)
updateString = updateString + ", ";
String colName = (String)colNames.get(b);
String colVals = (String)colValues.get(b);
if (colName.equals("BusName") || colName.equals("DisplayLine") || colName.equals("ProvDisp") || colName.equals("CityName") || colName.equals("PAC") || colName.equals("TeleNum"))
if (!((returned.getString(colName)).equals(colVals)))
createDelete = true;
updateString = updateString + colName + "='" + colVals + "'";
if (createDelete)
//create delete
String delFromQuickfixes = "DELETE FROM epsc_quickfixes WHERE Start_Date='" + Start_Date + "' AND Pub_ID='" + Pub_ID + "' AND QFix_Type='2';";
Statement delItm = conn1.createStatement();
delItm.execute(delFromQuickfixes);
String insertQfixDel = "INSERT INTO epsc_quickfixes SELECT *, '0' as UID, '" + Start_Date + "' as Start_Date, '" + Expiry_Date + "' as Expiry_Date, '2' as QFix_Type, '0' as ss, '" + force_noon + "' as force_noon FROM epsc_ypca WHERE Pub_ID='" + Pub_ID + "' AND (Record_Ind='2' OR Record_Ind='4' OR Record_Ind='6');";
Statement insertQFDEL = conn1.createStatement();
insertQFDEL.execute(insertQfixDel);
String updateRecords = "UPDATE epsc_ypca SET " + updateString + " WHERE Unique_ID='" + Unique_ID + "';";
String selectAndInsert = "INSERT INTO epsc_quickfixes SELECT *, '0' as UID, '" + Start_Date + "' as Start_Date, '" + Expiry_Date + "' as Expiry_Date, '3' as QFix_Type, '" + ss + "' as ss, '" + force_noon + "' as force_noon FROM epsc_ypca WHERE Pub_ID='" + Pub_ID + "';";
Statement insertIntoQfix = conn1.createStatement();
insertIntoQfix.execute(selectAndInsert);
out.write("Quickfix Successfully submitted.<BR><BR>\r\n");
catch (SQLException e)
out.write("<h1>SQL ERROR: " + e.getMessage() + "<BR><BR>Please report to administrator</h1>");
finally{
conn1.close();
%>
<BR><BR>[ <a href="menu.jsp">Return To Main</a> ]
</center>
</BODY>
</HTML>
<%
%>it is the exact same as the one i originally posted:
500 Servlet Exception
java.lang.ClassCastException
at quickfix0itm_0submit__jsp.addUpdate(/epsc/quickfix_itm_submit.jsp:24)
at quickfix0itm_0submit__jsp._jspService(/epsc/quickfix_itm_submit.jsp:169)
at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
at com.caucho.jsp.Page.subservice(Page.java:506)
at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
at com.caucho.server.http.Invocation.service(Invocation.java:315)
at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:344)
at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
at java.lang.Thread.run(Thread.java:534) -
Out.println() problems with large amount of data in jsp page
I have this kind of code in my jsp page:
out.clearBuffer();
out.println(myText); // size of myText is about 300 kbThe problem is that I manage to print the whole text only sometimes. Very often happens such that the receiving page gets only the first 40 kb and then the printing stops.
I have made such tests that I split the myText to smaller parts and out.print() them one by one:
Vector texts = splitTextToSmallerParts(myText);
for(int i = 0; i < texts.size(); i++) {
out.print(text.get(i));
out.flush();
}This produces the same kind of result. Sometimes all parts are printed but mostly only the first parts.
I have tried to increase the buffer size but neither that makes the printing reliable. Also I have tried with autoFlush="false" so that I flush before the buffer size gets overflowed; again same result, sometimes works sometimes don't.
Originally I use such a system where Visual Basic in Excel calls a jsp page. However, I don't think that this matters since the same problems occur if I use a browser.
If anyone knows something about problems with large jsp pages, I would appreciate that.Well, there are many ways you could do this, but it depends on what you are looking for.
For instance, generating an Excel Spreadsheet could be quite easy:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class TableTest extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
response.setContentType("application/xls");
PrintWriter out = new PrintWriter(response.getOutputStream());
out.println("Col1\tCol2\tCol3\tCol4");
out.println("1\t2\t3\t4");
out.println("3\t1\t5\t7");
out.println("2\t9\t3\t3");
out.flush();
out.close();
}Just try this simple code, it works just fine... I used the same approach to generate a report of 30000 rows and 40 cols (more or less 5MB), so it should do the job for you.
Regards -
How can i use this java program to access from a jsp page?
import java.io.*;
import java.util.*;
public class FileProcessing
//create a vector container for the input variables
Vector variables = new Vector();
//create a vector container for the constants
Vector constants = new Vector();
/*create a string expression container for the equation
as read from the file */
String expression = " ";
//create double result container for the final result
double result = 0;
public boolean processFile(String filename,String delim)
//index for values vector
int num_values = 0;
//index for constants vector
int num_constants = 0;
//current line being read from the external file.
String curline = " ";
//start reading from the external file
try
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
while(true)
curline = br.readLine();
if(curline == null)
break;
//determine the type of current interaction
boolean variable = curline.startsWith("input");
boolean constant = curline.startsWith("constant");
boolean equation = curline.startsWith("equation");
boolean output = curline.startsWith("result");
//on input variables
if(variable)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count=0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String inputval = (new String(b)).trim();
variables.add(num_values,inputval);
num_values++;
count++;
// on constant values
if(constant)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==1)
byte b[]= new byte[100];
System.out.println(temp);
System.in.read(b);
String cons = (new String(b)).trim();
constants.add(num_constants,cons);
num_constants++;
count++;
// on equation
if(equation)
StringTokenizer st = new StringTokenizer(curline,delim);
int num = st.countTokens();
int count = 0;
while(st.hasMoreTokens())
String temp = st.nextToken();
if(count==2)
this.expression = temp;
count++;
// now we are ready to evaluate the expression
if(output)
org.nfunk.jep.JEP myparser= new org.nfunk.jep.JEP();
myparser.setAllowAssignment(true);
for(int i=1;i<variables.size()+1;i++)
String name = "arg"+Integer.toString(i);
myparser.addVariable(name,new Double(variables.get(i-1)
.toString()).doubleValue());
for(int i=1;i<constants.size()+1;i++)
String name = "arg" +Integer.
toString(i+variables.size());
myparser.addConstant(name,new Double(constants.get(i-1).toString()));
//output is obtained as follows
myparser.parseExpression(expression);
result = myparser.getValue();
System.out.println("Assay value: "+result);
catch(Exception e)
System.out.println(e.toString());
return true;
public static void main(String[] args)
FileProcessing fp = new FileProcessing();
fp.processFile("input.eqn",":");
}here i need to generate the strings like 'enter value1' and respective text boxes dynamically . i should use this java program as business logic and a jsp page for view.
following given is my text file input.eqn
input:enter value1:arg1
input:enter value2:arg2
input:enter value3:arg3
constant:enter constant1:arg4
constant:enter constant2:arg5
equation:enter equation:(arg1+arg2)*(arg3+arg4)*arg5
result:Why do you double post ? http://forum.java.sun.com/thread.jspa?threadID=646988&tstart=0
Why dint that answer satisfy you ? And why dint you say so in that thread rather than posting the same question again ?
ram. -
Java.lang.ClassCastException in JSP page
My JSP page:
<%@page contentType="text/html"%>
<HTML>
<HEAD>
<TITLE> JDBC Servlet/JSP Example </TITLE>
</HEAD>
<BODY>
<%@ page import="myBeans.memoryBean" %>
<%@ page import="java.util.Vector" %>
<H1> JDBC Servlet/JSP Example </H1>
<H2> <%= session.getValue("message") %>
</H2>
<UL>
<%
Vector vData = (Vector) session.getValue("res");
myBeans.memoryBean mb;
Object o;
for (Enumeration e = vData.elements() ; e.hasMoreElements() ;) {
o = e.nextElement();
mb = (myBeans.memoryBean) o;
%>
<LI> <%= o.getClass().getName() %>
<% } // end for
%>
</UL>
</BODY>
</HTML>Notice that I don't even use the object I cast but I still get the error message:
Exception:
java.lang.ClassCastException
at _memory._search._jspService(_search.java:66)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
at oracle.jsp.JspServlet.internalService(JspServlet.java)
at oracle.jsp.JspServlet.service(JspServlet.java)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
at org.apache.jserv.JServConnection.run(JServConnection.java:188)
at java.lang.Thread.run(Thread.java:534)When I comment out the line that castes my object my browser displays:
JDBC Servlet/JSP Example
Records Found:
* myBeans.memoryBean
* myBeans.memoryBean
* myBeans.memoryBean Notice that the three objects that are returned are exactly the type that I caste to.
Also, I did a getClass().getClassLoader() when I create the objects in my servlet code and again on the JSP pages for each object I pull out of the vector and the class loader matched.
I even changed the package on my bean class and recompiled everything to make sure it wasn't a old .class file floating around.
Could this have something to do with my classpath or where my classes are being placed? I found a similar problem here: http://forum.java.sun.com/thread.jsp?forum=33&thread=380437&start=0&range=15&hilite=false&q=
but the explanation of what was done wasn't clear
Anyone have any idea what's going on here?
I am using:
Oracle 9i
Oracle HTTP Server Powered by Apache/1.3.12 (Unix)
ApacheJServ/1.1
Thanks in advance.
- LinusIs ti at all possible that you have another jar / zip file with the same class file in it, seemingly away from the Server classpath ? In which case this could happen even though logically it shouldn't !!!
-
I have some dates fields on JSP page I want to store data in mysql databse. Can someone tell me how I can format dates as I do for other data types in servlet before I send data to add in databse: such as
For int type data:
String paymentID = request.getParameter("PaymentID")
I format it like this for class Payment.
Payment newPayment(int.parseInt(paymentID)
how do i work with date fields this is what I Am trying to do:
Code patches....
import java.text.DateFormat;\import java.text.ParseException;
public date date1;
try
date1= format.parse(paymentStartDate);
catch(ParseException pe)
System.out.println("Problem found");
....I do not get any error but it leaves date fields empty because date1 formatting never goes to try... Always say "Problem found on console"
Any help?I just realized I should post the whole file... here is code of the servlet that recieved dates from JSP and process it.
package admin;
import java.lang.Object.*;
import java.text.DateFormat;
import java.util.Date;
import java.io.IOException;
import java.text.ParseException;
import data.*;
import business.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class AddPaymentServlet extends HttpServlet{
public Date date1;
public Date date2;
public DateFormat format;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
// Stores user entered Payment information in variables to create new Payment vector
String paymentID = request.getParameter("paymentID");
String clientName = request.getParameter("clientName");
String paymentType = request.getParameter("paymentType");
String paymentAmount = request.getParameter("paymentAmount");
String paymentStartDate = request.getParameter("paymentStartDate");
String paymentExpiryDate = request.getParameter("paymentExpiryDate");
String paymentDescription = request.getParameter("paymentDescription");
String paymentState1 = request.getParameter("paymentState"); // use String type of PaymentType
//-----------------------------------Format dates----------------------------------------------------------
DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.SHORT);
// System.out.println("Date1--->"+date1);
try
{ date1 = format.parse(paymentStartDate);
// System.out.println("Date1--->"+date1);
catch(ParseException ps)
System.out.println("can't format dates");
try
date2 = format.parse(paymentExpiryDate);
catch(ParseException pe)
System.out.println("can't format dates");
// get old Payment object from session
//--------------------------------Send new PAyment Information to Vector Payment in Payment.jave-----------------------------
Payment newPayment = new Payment(clientName,paymentType,Double.parseDouble(paymentAmount),date1,date2,paymentDescription,paymentState1);
//------------------------------ Call PaymentDB function Add() to store new payment infomration in the databse
PaymentDB.addRecord(newPayment);
// over-write Payment object in session
request.getSession().setAttribute("payment",newPayment);
request.getSession().setAttribute("payments",PaymentDB.readRecords());
//---------------------------------- Send results back to payment.jsp for updated information----------------------
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/Admin/payments.jsp");
dispatcher.forward(request, response);
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
doGet(request, response);
} -
DMS Console Exception in JSP Page
Hello. I have a simple jsp page that calls a method in a class file. In the class I have a function, where I get an error when the connection is attempted.
I know that the connection is the problem because the jsp page calls it ( <%=opduser.count()%>) fine when the connection line is commented out. The error is posted below, I have ojdbc14_g, and classes12_dms, classes12_g jar files in my classpath, I have tried different combinations of jars as well.
THANKS IN ADVANCE
JAVA CODE
package world;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.sql.*;
import oracle.jdbc.driver.OracleDriver;
import javax.servlet.*;
import java.text.*;
import java.util.*;
//import util.HTMLFilter;
import javax.servlet.jsp.tagext.*;
import java.sql.*; // Package for JDBC core API
import javax.naming.*;
//import oracle.jdbc.pool.OracleDataSource; // Oracle Data source class
import javax.servlet.Filter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.Vector;
import java.lang.*;
public class opd// extends HttpServlet
//HttpServletResponse response;
public int count()throws IOException, SQLException{
int number=-1;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@Oracle9ia:1521:xxxxx", "xxx", "xxx Statement stmt = conn.createStatement();
Statement stmt2 = conn.createStatement();
ResultSet rset = stmt.executeQuery("select * from project_access_passwords where project_user='opd'");
rset.next();
number=rset.getInt(3);
number++;
stmt2.executeUpdate("update project_access_passwords set project_access='"+number+"' where project_user='opd'");
stmt2.executeUpdate("commit");
catch(Exception e){}
return number;
ERROR RECEIVED
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: oracle/dms/console/DMSConsole
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.opd_005findex_jsp._jspService(opd_005findex_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.lang.NoClassDefFoundError: oracle/dms/console/DMSConsole
oracle.jdbc.driver.DMSFactory.<clinit>(DMSFactory.java:28)
oracle.jdbc.driver.OracleConnection.createDMSSensors(OracleConnection.java:662)
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:325)
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:521)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:325)
java.sql.DriverManager.getConnection(DriverManager.java:512)
java.sql.DriverManager.getConnection(DriverManager.java:171)
world.opd.count(opd.java:39)
org.apache.jsp.opd_005findex_jsp._jspService(opd_005findex_jsp.java:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs.Hi,
Could you find a solution to this problem..? I am also getting the same kind of error. If so, kindly email me at : [email protected]
Thanks,
Jyoti. -
Passing parameters from a Java class to Jsp page
Hi everybody. I'm newbie in using Java class in conjunction with JSP pages. Infact I have a problem. How can I pass the parameters used in a Java class (as UserName, Password, and so on..) to a JSP page? What methods (and classes) I have to use?
Thank you in advance
Have a nice dayIt still doesn't work. I write the code
//my java class
package channel_service;
import java.util.Vector;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2002</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
public class CallMenu {
private Vector parameters = new Vector();
public void setParameters( String UserId ) {
parameters.add(0, UserId);
//parameters.add(2, Pin);
//parameters.add(3, UserName);
//parameters.add(4, Greeting);
public Vector getParameters() {
return parameters;
//my jsp page
<%@ page import="Channel_Service.src.channel_service.CallMenu" %>
<%@ page import="java.util.Vector" %>
<html>
<head><title>User Menu Page</title></head>
<body>
<center><h1><i><b>This is your personal User Menu page</b></i></h1></center>
<br>
<br>
<center><h2><i>In the list below you'll find all your personal information (as UserID, Password and so on...)
and all the function you have the rights to use</i></h2></center>
<br>
<br>
<table align=center>
<tr>
<%
CallMenu cl = new CallMenu();
cl.setParameters();
Vector params = cl.getParameters();
String UserId = (String)params.elementAt(0);
String Pin = (String)params.elementAt(1);
String UserName = (String)params.elementAt(2);
String Greeting = (String)params.elementAt(3);
%>
<td><h2><b><i>User ID = <%= UserId %></td></tr>
<tr><td><h2><b><i>PIN = <%= Pin %></td></tr>
<tr><td><h2><b><i>User Name = <%= UserName %></td></tr>
<tr><td><h2><b><i>The system says <%= Greeting %></td></tr>
</table>
</body> -
Passing value from JApplet to Jsp page
Hello,
How can i pass a value that is entered in a JTextArea in a JApplet and fetch the entered value from JTextArea and display it in a JSP page.
It would be kindful if someone could help me with this problem.
Regards
Sanamhello,
Thanks for ur reply,
Sorry to say that i did not understand where to implement ur code in my code.
Below is my code could u plz tell me where do i put in ur code.
My code works fine u can compile it.
javac *.java;
appletviewer BIA.java
Can u plz tell the JSP code.
It would be very kindful if u could please help me.
Thank you
//**************** BIA.java***********
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.util.Vector;
import java.applet.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;
import java.lang.reflect.Field;
<applet code = "BIA" width = 500 height = 500>
</applet>
public class BIA extends JApplet
public static Container cp;
public BIAP panel;
public TB action;
public void init()
panel = new BIAP();
action = new TB(panel);
action.setLayout(new GridLayout(2,2));
cp = getContentPane();
cp.setLayout(new BorderLayout());
cp.add(action, "North");
cp.add(new JScrollPane(panel));
repaint();
//******************* BIAP.java*************
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.util.Vector;
import java.applet.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;
import java.lang.reflect.Field;
class BIAP extends JPanel
public BIA bia;
public BufferedImage image;
public double scale, scaleInc;
public JTextArea jt;
public BIAP()
loadImage();
setBackground(Color.white);
scale = 1.0;
scaleInc = 0.01;
setLayout(null);
jt = new JTextArea("Welcome");
jt.setBounds(0,0, 90,30);
add(jt);
repaint();
protected void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
int w = getWidth();
int h = getHeight();
int imageWidth = image.getWidth();
int imageHeight = image.getHeight();
int x = (w - imageWidth)/2;
int y = (h - imageHeight)/2;
g2.drawImage(image, x, y, this);
private void loadImage()
String fileName = "Terragen___Losing_Grip_by_Blackheart6004.jpg";
try
URL url = getClass().getResource(fileName);
System.out.println(url);
image = ImageIO.read(url);
catch(MalformedURLException mue)
System.out.println("url: " + mue.getMessage());
catch(IOException ioe)
System.out.println("read: " + ioe.getMessage());
public Dimension getPreferredSize()
Dimension d = new Dimension();
d.width = (int)(scale * image.getWidth());
d.height = (int)(scale * image.getHeight());
return d;
//method used for Zoom Operation
public void setScale (int inc)
scale += inc * scaleInc;
revalidate();
repaint();
//************************** TB*********************
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.util.Vector;
import java.applet.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;
class TB extends JPanel
BIAP panel;
JButton save = new JButton("Save");
public TB(BIAP biap)
panel = biap;
ActionListener sa = new ActionListener()
public void actionPerformed(ActionEvent e)
JButton button = (JButton)e.getSource();
if(button == save)
//panel.fileSave();
save.addActionListener(sa);
add(save);
}
Maybe you are looking for
-
On an iphone 4s, when I tap the phone number in my contacts list instead of calling the number it goes to a "Welcome to mail" screen with icloud, Microsoft exchange, Gmail, Yahoo, Aol & Windows Live Hotmail listed beneath. How do I make it call the n
-
BAPI to update customer details
Hi All, What is the BAPI that we should use to update customer details into SAP?? What are the mandatory fields we need to update customer record in SAP? Thx Navin
-
BPM SEND step with Acknowledgemnt.Process logic depends on Application Ack.
Hi, I am designing one BPM process in which I want to send IDOC to R/3.This IDOC will be processed by the R/3 system using process code. Now I have sent this IDOC to R/3 through send step with application acknowledgment and only if acknowledgment com
-
I keep getting a message that says error occurred 0X8002006e what do I do?
When I try to burn a cd, a message comes up and says an error has occurred 0x8002006E, what do I need to do to be able to burn cd?
-
I trying to import an audio file (MP3) to a Menu of iDVD (7.04), the one called "Bands", and when I play a Preview DVD Playback, I cannot hear anything. I draged the audio file to the Audio area of the inspector (CMD+I). Is there some kind of update