Passing variable in a method bean to JSP Page
Hello Everyone,
Can I Have a quick example of passing method variables from a java bean to a JSP page, (no forms involved)
thanks
Hello again,
maybe I didn't explain my self correctly,
I have a java program that read's from an external file. The program tokenizes the file (I use String Tokenizing). What I want is for the Tokenized string to display on a JSP page, How do I accomplish this?
Below is a small fragment of my string Tokenizing program: Please I need help.
package dev;
import java.io.*;
import java.util.*;
public class RoundDetail2
public static final String SUITS[] = {" ", "Clubs", "Hearts", "Spades", "Diamonds", "Joker", "FaceDown"};
public static final String VALUES[] = {"Joker ","Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
public static final String SuitVALUES[] = {" ","1","2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"};
public RoundDetail2() throws FileNotFoundException
DataInputStream inFile=
new DataInputStream(
new BufferedInputStream(
new FileInputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/WEB-INF/classes/dev/Data_452SY2.txt")));
DataOutputStream outFile = new DataOutputStream(
new FileOutputStream("C:/apps/jakarta-tomcat-4.0.6/webapps/ROOT/dev/jsp/wager_history.jsp"));
String readDetail_topLayer;
try
while((readDetail_topLayer = inFile.readLine()) != null)
StringTokenizer tokenizer_topLayer = new StringTokenizer(readDetail_topLayer,"\t");
while (tokenizer_topLayer.hasMoreTokens())
String string_gameID = tokenizer_topLayer.nextToken();
String string_roundID = tokenizer_topLayer.nextToken();
String string_bet = tokenizer_topLayer.nextToken();
String string_win = tokenizer_topLayer.nextToken();
String string_roundDetail = tokenizer_topLayer.nextToken();
String string_date_time = tokenizer_topLayer.nextToken();
System.out.println ("test tab!" + string_gameID);
Similar Messages
-
Calling function from Backing Bean or JSP page
We are on Jdeveloper 10.1.3.3.0, ADF Faces, JSF Faces .., Currently there is a function call from Javascript event (onmouseover) in the JSP page. I want to call this function from a backing bean or JSP page, as I have to pass some values to this function.
For Ex., I have a function call like return submit('A','B','Test'); on the Javascript event (onmouseover) in jsp page. I want to remove this function from the javascript event and call from backing bean or jsp page to pass some values into the submit() function. I appreciate if anyone can give some example of how to call this function from backing bean or jsp page in the <SCRIPT> or <SCRIPTLET>
Thanks,
RamA use case would be helpful so that we can get a better idea of what you want to do.
As a general rule, there is no way to call a client side Javascript function from a backing bean, which is server side. However, there are ways to inject information from a backing bean into your Javascript call. For instance, I have an application that uses Google Maps API. It has an onload call to a Javascript function that builds the map and designates it's center point. The center point comes from a backing bean as latitude and longitude properties. So here is my body tag:
<afh:body onload="initialize(#{backing_searchResults.latitude},#{backing_searchResults.longitude},#{searchCriteria.distance})"
onunload="GUnload()">onload calls the Javascript function called initialize, and passes the latitude, longitude, and distance from the bean. Is the function really being called from my backing bean? No - the parameters are hard coded into the onload event code when the page is rendered. Does it do the job? Sure it does. -
How to debug a bean in JSP page with JBX???
How to debug a bean in JSP page with JBX???
i have a bean within a JSP page. i wanna find out how do they varibles work and changes of them values.
are there some ways or tools to get the situations of them in visual way? just like when i debug VB program,i can get the situations in immediately window.help me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
hi,
I tried to my best to call java beans from JSP page but it generate error that "unable to load class....", please help me that in which directory jsp file and bean *.class file reside, currently my setting are as follows.
Note: I am using tomcat server and my jsp and servlet files are running seccessfuly, there is any special change in classpath for java beans? if any please tell
My jsp file is in tomcat-->webapps-->jsp--><my file>
My bean (*.class) file-->webapps-->Root-->web-inf-->classes--><my file>
Pleae help me for the above problem.
Mubashar ([email protected])According to J2EE standards:
The web appl directory structure should be:
WebAppRootDirectory
|
|---html, jsp, images etc
|
|---WEB-INF---
|---classes--
|---lib
|
|
1) Make sure WEB-INF is in capital letters
2) Place all ur beans in classes dir or sub-directory in
classes
3) In Tomcat place WebAppRootDirectory in webapps
directory
[email protected] -
How to execute a backing-bean method before loading JSP Page?
Hi everybody.
Scene:
An AdfForm, with
-SelectChoice, referenced to a <list> of pageDef, which is referenced to an ADF BC.
Goal:
-Executing the query of the ADF BC before load the SelectChoice, to load the correct values.
A good question to know:
Exists any way to execute a method of backing before loading a JSP Page?
Any similar to onload method of javascript. It could be fantastic.
Thanks in advance,
Jaimehi Jaime
If I understand correctly, you are using the ADF Model for data binding.
Because your goal is "Executing the query of the ADF BC ...", maybe you can also consider to refresh an executable in your Page Definition.
See also "10.5.5 How to Use Refresh Correctly for InvokeAction and Iterator Bindings"
at http://download.oracle.com/docs/html/B25947_01/bcdcpal005.htm#BJECHBHF
It says "... You can use the Refresh property on iterator bindings and invokeAction executables in your page definition to control when each are evaluated during the ADF page lifecycle, either during the prepareModel phase, the prepareRender phase, or both. ...".
Although you have posted your question in a structured way, which is a good thing, I think it would help to understand your question if you can explain how you determine "the correct values" for your list, what is varying?
success
Jan Vervecken -
How to use value returned from a bean in jsp page
Hi All,
I have a string array value being returned from a javabean to a jsp page. I want to be able to assign the value to a variable in the jsp page.
How do I do this?
Many thanks :)thanks for your response.
I actually used something like this:
<% String loggedin = log.User(user,password);
out.println(loggedin);
%>i am not yet as much of an expert on beans as i would like to be, but i thought it is not really a bean if it has a getter method which takes arguments? -
How can we pass selected combo box value to a jsp pag?
Hi All,
I want to pass selected combo box value to a same jsp page's variable.
i am using javascript
<select onchange="this.options[this.selectedIndex].text">
</select>
this selected value should be invoked for a jsp page's variable.
Excepting for favorable reply
Vanshselect2.jsp
<script>
function x()
alert(document.f.s.options[document.f.s.selectedIndex].text);
document.f.submit();
</script>
<body>
<form method="get" name="f" action="select2.jsp">
<select name="s" onchange="x()">
<option checked>--select--</option>
<option value="1"> vijay </option>
<option value="2"> kumar </option>
</select>
</form>
</body> -
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> -
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 call a class method from a jsp page?
Hi all,
i would like to create a basic jsp page in jdev 1013 that contains a button and a text field. When clicking the button, i would like to call a method that returns a string into the text field.
The class could be something like this:
public class Class1 {
public String getResult() {
return "Hello World";
How do i go about this?
ThanksHere is a sample:
HTML><HEAD><TITLE>Test JDBC for Oracle Support</TITLE></HEAD><BODY>
<%@ page import="java.sql.*, oracle.jdbc.*, oracle.jdbc.pool.OracleDataSource" %>
<% if (request.getParameter("user")==null) { %>
<FORM method="post" action="testjdbc.jsp">
<H1>Enter connection Parameters</H1>
<H5>Please enter host name:</H5><INPUT TYPE="text" name="hostname" value="localhost" />
<H5>Please enter port number:</H5><INPUT TYPE="text" name="port" value="1521" />
<H5>Service nanme:</H5><INPUT TYPE="text" name="service" value="XE" />
<H5>Please enter username: </H5><INPUT TYPE="text" name="user" />
<H5>Please enter password</H5><INPUT TYPE="password" name="password" />
<INPUT TYPE="submit" />
</FORM>
<% } else { %>
<%
String hostName = request.getParameter("hostname");
String portNumber = request.getParameter("port");
String service = request.getParameter("service");
String user = request.getParameter("user");
String password = request.getParameter("password");
String url = "jdbc:oracle:thin:" + user + "/" + password + "@//" + hostName + ":" + portNumber + "/" + service;
try {
OracleDataSource ods = new OracleDataSource();
ods.setURL(url);
Connection conn = ods.getConnection();
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver information
out.println("<TABLE>");
out.println("<TR><TD>");
out.println("<B>JDBC Driver version</B>");
out.println("</TD>");
out.println("<TD>");
out.println(meta.getDriverVersion());
out.println("</TD>");
out.println("</TR>");
out.println("<TR><TD>");
out.println("<B>JDBC Driver Name</B>");
out.println("</TD>");
out.println("<TD>");
out.println(meta.getDriverName());
out.println("</TD>");
out.println("</TR>");
out.println("<TR><TD>");
out.println("<B>JDBC URL</B>");
out.println("</TD>");
out.println("<TD>");
out.println(meta.getURL());
out.println("</TD>");
out.println("<TABLE>");
conn.close();
} catch (Exception e) {e.printStackTrace(); }
%>
<%-- end else if --%>
<% } %>
</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) -
How to read all rows stored in pojo bean from jsp page
Hi sir
After storing all rows into ArrayList object in pojo class, how to retrieve those rows from jsp page and display them together one by one.
RegardsWell, you wouldn't do it in Java. You would do it in JSTL, preferably.
So if your POJO had a getRows method which returned your List of row objects, you would get the list like this (after putting the POJO into request scope under the name of "pojo"):
${pojo.rows}
And if you wanted to go through that list and process each of the rows, then c:forEach would be the way:
<c:forEach value="row" items="${pojo.rows} />
(check the documentation, I'm posting this from memory) -
Accessing a java class method from the jsp page.
Hi im a beginner with jsp and im trying to find a way to access a method of my java class file in jsp page. After searching through the forums i tried to use the usebean tag. Im using apache to host the jsp file.Below is an excerpt of my code and the error message i got. What am i doing wrong? anyone know?
<%@ page language="java" %>
<jsp:useBean id="movies" class="movie.Movie" />
<jsp:setProperty name="movies" property="*"/>
<%
movies.getStart("file:///C:/Video/Applications2/sun.mpg");
response.setContentType("text/xml");
%>
exception
org.apache.jasper.JasperException: Exception in JSP: /View.jsp:7
4: <jsp:setProperty name="movies" property="*"/>
5: <%
6:
7: movies.getStart("file:///C:/Video/Applications2/sun.mpg");
8: response.setContentType("text/xml");
9: %>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: javax/media/ControllerListenerHi thanks for responding. Ok i did look through and it was opening some gui. I still need the program to do server side processes so cant use an applet.but i dont need the gui so i revised it and removed the gui. also im using a servlet to call the class now yet i still have the same error. Any ideas?
Below is the vid2jpg code minus the gui.
import java.io.*;
import java.awt.*;
import javax.media.*;
import javax.media.control.*;
import javax.media.format.*;
import javax.media.protocol.*;
import java.awt.image.*;
import javax.imageio.*;
public class vid2jpg implements ControllerListener
Processor p;
Object waitObj = new Object();
boolean stateOK = true;
DataSourceHandler handler;
int imgWidth;int imgHeight;
Image outputImage;
String sep = System.getProperty("file.separator");
int[] outvid;
int startFr = 1;int endFr = 1000;int countFr = 0;
boolean sunjava=true;
* Static main method
public static void main(String[] args)
if(args.length == 0)
System.out.println("No media address.");
new vid2jpg("file:///C:/Video/applications2/sun.mpg"); // or alternative "vfw://0" if webcam
else
String path = args[0].trim();
System.out.println(path);
new vid2jpg(path);
* Constructor
public vid2jpg(String path)
MediaLocator ml;String args = path;
if((ml = new MediaLocator(args)) == null)
System.out.println("Cannot build media locator from: " + args);
if(!open(ml))
System.out.println("Failed to open media source");
* Given a MediaLocator, create a processor and start
private boolean open(MediaLocator ml)
System.out.println("Create processor for: " + ml);
try
p = Manager.createProcessor(ml);
catch (Exception e)
System.out.println("Failed to create a processor from the given media source: " + e);
return false;
p.addControllerListener(this);
// Put the Processor into configured state.
p.configure();
if(!waitForState(p.Configured))
System.out.println("Failed to configure the processor.");
return false;
// Get the raw output from the Processor.
p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW));
TrackControl tc[] = p.getTrackControls();
if(tc == null)
System.out.println("Failed to obtain track controls from the processor.");
return false;
TrackControl videoTrack = null;
for(int i = 0; i < tc.length; i++)
if(tc.getFormat() instanceof VideoFormat)
tc[i].setFormat(new RGBFormat(null, -1, Format.byteArray, -1.0F, 24, 3, 2, 1));
videoTrack = tc[i];
else
tc[i].setEnabled(false);
if(videoTrack == null)
System.out.println("The input media does not contain a video track.");
return false;
System.out.println("Video format: " + videoTrack.getFormat());
p.realize();
if(!waitForState(p.Realized))
System.out.println("Failed to realize the processor.");
return false;
// Get the output DataSource from the processor and set it to the DataSourceHandler.
DataSource ods = p.getDataOutput();
handler = new DataSourceHandler();
try
handler.setSource(ods); // also determines image size
catch(IncompatibleSourceException e)
System.out.println("Cannot handle the output DataSource from the processor: " + ods);
return false;
// setLayout(new FlowLayout(FlowLayout.LEFT));
// currPanel = new imgPanel(new Dimension(imgWidth,imgHeight));
// add(currPanel);
// pack();
//setLocation(100,100);
// setVisible(true);
handler.start();
// Prefetch the processor.
p.prefetch();
if(!waitForState(p.Prefetched))
System.out.println("Failed to prefetch the processor.");
return false;
// Start the processor
//p.setStopTime(new Time(20.00));
p.start();
return true;
* Sets image size
private void imageProfile(VideoFormat vidFormat)
System.out.println("Push Format "+vidFormat);
Dimension d = (vidFormat).getSize();
System.out.println("Video frame size: "+ d.width+"x"+d.height);
imgWidth=d.width;
imgHeight=d.height;
* Called on each new frame buffer
int nextframetime = 0;
private void useFrameData(Buffer inBuffer)
try
if(inBuffer.getData()!=null) // vfw://0 can deliver nulls
if(sunjava) // and with import javax.imageio.*;
int frametimesecs = (int)(inBuffer.getTimeStamp()/1000000000);
if(frametimesecs%10 == 0 && frametimesecs==nextframetime)
nextframetime+=10;
BufferedImage bi = new BufferedImage(outputImage.getWidth(null), outputImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
Graphics g = bi.getGraphics();
ImageIO.write(bi, "png", new File("images"+sep+"image_"+(inBuffer.getTimeStamp()/1000000000)+".png"));
catch(Exception e){}
* Tidy on finish
public void tidyClose()
handler.close();
p.close();
* Block until the processor has transitioned to the given state
private boolean waitForState(int state)
synchronized(waitObj)
try
while(p.getState() < state && stateOK)
waitObj.wait();
catch (Exception e)
return stateOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt)
if(evt instanceof ConfigureCompleteEvent || evt instanceof RealizeCompleteEvent || evt instanceof PrefetchCompleteEvent)
synchronized(waitObj)
stateOK = true;
waitObj.notifyAll();
else
if(evt instanceof ResourceUnavailableEvent)
synchronized(waitObj)
stateOK = false;
waitObj.notifyAll();
else
if(evt instanceof EndOfMediaEvent || evt instanceof StopAtTimeEvent)
tidyClose();
* Inner classes
* A DataSourceHandler class to read from a DataSource and displays
* information of each frame of data received.
class DataSourceHandler implements BufferTransferHandler
DataSource source;
PullBufferStream pullStrms[] = null;
PushBufferStream pushStrms[] = null;
Buffer readBuffer;
* Sets the media source this MediaHandler should use to obtain content.
private void setSource(DataSource source) throws IncompatibleSourceException
// Different types of DataSources need to handled differently.
if(source instanceof PushBufferDataSource)
pushStrms = ((PushBufferDataSource) source).getStreams();
// Set the transfer handler to receive pushed data from the push DataSource.
pushStrms[0].setTransferHandler(this);
// Set image size
imageProfile((VideoFormat)pushStrms[0].getFormat());
else
if(source instanceof PullBufferDataSource)
System.out.println("PullBufferDataSource!");
// This handler only handles push buffer datasource.
throw new IncompatibleSourceException();
this.source = source;
readBuffer = new Buffer();
* This will get called when there's data pushed from the PushBufferDataSource.
public void transferData(PushBufferStream stream)
try
stream.read(readBuffer);
catch(Exception e)
System.out.println(e);
return;
// Just in case contents of data object changed by some other thread
Buffer inBuffer = (Buffer)(readBuffer.clone());
// Check for end of stream
if(readBuffer.isEOM())
System.out.println("End of stream");
return;
// Do useful stuff or wait
useFrameData(inBuffer);
public void start()
try{source.start();}catch(Exception e){System.out.println(e);}
public void stop()
try{source.stop();}catch(Exception e){System.out.println(e);}
public void close(){stop();}
public Object[] getControls()
return new Object[0];
public Object getControl(String name)
return null;
below is the servlet code.
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class ShowMovie extends HttpServlet {
String rootURL="http://127.0.0.1:8080/Video/";
public void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//String movie=request.getParameter("movie");
String movie ="son";
getStart(movie);
response.sendRedirect(rootURL+"View.jsp");
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
public void getStart(String url){
new vid2jpg(url);
this is the error from the server. Im using tomkat 5
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: javax/media/ControllerListener
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(Unknown Source)
java.security.SecureClassLoader.defineClass(Unknown Source)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
java.lang.ClassLoader.loadClassInternal(Unknown Source)
ShowMovie.getStart(ShowMovie.java:31)
ShowMovie.processRequest(ShowMovie.java:14)
ShowMovie.doGet(ShowMovie.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs. -
Passing values at run time through a JSP page to selection formula to crystal report
<p>hi,</p><p> i am using one jsp page.in that page there is a field to select a date </p><p>this value will go to the report and report contain one selection formula.</p><p>which value we are passing on that basis the report should display</p><p>with date which we are passing from GUI.</p><p>help.............................................................</p><p>//R</p>
I believe the value of this is based on the owner of the scheduled object. So if the Admin is scheduling it on behalf of a user I think it should use the user the Admin scheduled on behalf of. It should be simple to test, simply create a report with this value being displayed and nothing else and see what values you get.
-
Could not invoke the service() method when the JSP page is loaded
I am new to servlets/jsp so excuse if I am doing something silly here:
I have a JSP page the suppose to be loading a session attrbute from a simple servlet. When I go to load the jsp page, I get Could not invoke the service() method.
Any help is much appreciated:
Here is my JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" import="insurance.PolicyObj,java.util.*"%>
<% Vector VTable = (Vector) session.getAttribute("policyTable"); %>
<HTML>
<BODY>
<Form name=listTable action="InsSer" method="post">
<TABLE border="1">
<TBODY>
<TR>
<TD width="258" align="center"><B>Policy Id</B></TD>
<TD width="187" align="center"><B>Customer Name</B></TD>
<TD width="160" align="center"><B>Agent Name</B></TD>
<TD width="134" align="center"><B>Status</B></TD>
</TR>
<TR>
<%
for (int index=0; index < VTable.size();index++) {
PolicyObj TableL = (PolicyObj) VTable.elementAt(index);
%>
<TR bgcolor="#99CCFF">
<TD width="258" align="center"> <%= TableL.getPolicyId()%> </TD>
<TD width="187" align="center"> <%= TableL.getCustomerName()%> </TD>
<TD width="187" align="center"> <%= TableL.getAgentName() %> </TD>
<TD width="187" align="center"> <%= TableL.getPolicyStatus() %></TD>
</TR>
<% } %>
</TBODY>
</TABLE>
<P><INPUT type="submit" name="Submit" value="Refresh Active Policies"></P>
</BODY>
</HTML>
Here is my servlet:
package insurance;
import java.io.IOException;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class InsSer extends HttpServlet implements Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
public InsSer() {
super();
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest arg0, HttpServletResponse resp)
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req,resp);
// TODO Auto-generated method stub
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest arg0, HttpServletResponse resp)
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//PolicyObj[] policyTable = new PolicyObj[3];
HttpSession session = req.getSession(false);
//if (session == null) {
//resp.sendRedirect("http://localhost:9080/Insurance/error.html");
//Vector buylist = (Vector) session.getAttribute("PolicyList");
Vector policyList = null;
policyList.addElement(new PolicyObj());
((PolicyObj) policyList.get(0)).setPolicyId("0009800002");
((PolicyObj) policyList.get(0)).setCustomerName("Salim Zeitouni");
((PolicyObj) policyList.get(0)).setAgentName("Jack Smith");
((PolicyObj) policyList.get(0)).setPolicyStatus("Pending");
session.setAttribute("policyTable",policyList);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("InsSev1.jsp");
rd.forward(req,resp);
Message was edited by:
sfz1
Message was edited by:
sfz1I am new to servlets/jsp so excuse if I am doing something silly here:
I have a JSP page the suppose to be loading a session attrbute from a simple servlet. When I go to load the jsp page, I get Could not invoke the service() method.
Any help is much appreciated:
Here is my JSP:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page session="true" import="insurance.PolicyObj,java.util.*"%>
<% Vector VTable = (Vector) session.getAttribute("policyTable"); %>
<HTML>
<BODY>
<Form name=listTable action="InsSer" method="post">
<TABLE border="1">
<TBODY>
<TR>
<TD width="258" align="center"><B>Policy Id</B></TD>
<TD width="187" align="center"><B>Customer Name</B></TD>
<TD width="160" align="center"><B>Agent Name</B></TD>
<TD width="134" align="center"><B>Status</B></TD>
</TR>
<TR>
<%
for (int index=0; index < VTable.size();index++) {
PolicyObj TableL = (PolicyObj) VTable.elementAt(index);
%>
<TR bgcolor="#99CCFF">
<TD width="258" align="center"> <%= TableL.getPolicyId()%> </TD>
<TD width="187" align="center"> <%= TableL.getCustomerName()%> </TD>
<TD width="187" align="center"> <%= TableL.getAgentName() %> </TD>
<TD width="187" align="center"> <%= TableL.getPolicyStatus() %></TD>
</TR>
<% } %>
</TBODY>
</TABLE>
<P><INPUT type="submit" name="Submit" value="Refresh Active Policies"></P>
</BODY>
</HTML>
Here is my servlet:
package insurance;
import java.io.IOException;
import java.util.Vector;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class InsSer extends HttpServlet implements Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
public InsSer() {
super();
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest arg0, HttpServletResponse resp)
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req,resp);
// TODO Auto-generated method stub
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest arg0, HttpServletResponse resp)
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//PolicyObj[] policyTable = new PolicyObj[3];
HttpSession session = req.getSession(false);
//if (session == null) {
//resp.sendRedirect("http://localhost:9080/Insurance/error.html");
//Vector buylist = (Vector) session.getAttribute("PolicyList");
Vector policyList = null;
policyList.addElement(new PolicyObj());
((PolicyObj) policyList.get(0)).setPolicyId("0009800002");
((PolicyObj) policyList.get(0)).setCustomerName("Salim Zeitouni");
((PolicyObj) policyList.get(0)).setAgentName("Jack Smith");
((PolicyObj) policyList.get(0)).setPolicyStatus("Pending");
session.setAttribute("policyTable",policyList);
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher("InsSev1.jsp");
rd.forward(req,resp);
Message was edited by:
sfz1
Message was edited by:
sfz1
Maybe you are looking for
-
IPhone5 not showing up in devices tab on iMac, can't transfer songs from computer to phone
I have a new iPhone5 and an iMac running Snow Leopard. I have scads of songs on my computer that are mostly from CDs. When I hooked the new phone up to the computer, the newly purchased songs on the phone loaded onto the computer automatically. Ho
-
Hi I have configured a receiver file adapter to send an XML message to a file directory. The structure is <?xml version="1.0" encoding="UTF-8" ?> - <ns0:MT_SiteDetails_MM xmlns:ns0="urn:Retail.net:SiteDetails"> - <ROWSET> - <ROW> <ext_cust_id>00
-
AC3 Collison detection inside a movie clip (rather than with its bounding box)
I want to navigate a maze and therefore I want to create collison detection with the maze itself, but when I try the collison is made with the entire maze movieclip, so even if my character is safe in a corridor without touching the walls of the maze
-
Is the 27" iMac display exactly the same as the 27" ACD?
I'm looking at updating my existing set up and want to know whether the above displays are exactly the same. From memory the ACD's were usually of a better quality compared to the iMac displays. Have they achieved parity now? Where will I find full
-
if i get an i pad with 3 g service capability do i have to use it in order for the i pad to work or can i just use the wifi part because i dont have the extra money to pay for a data plan