ClassCastException with JSP
I'm getting this weird exception when I load a jsp form:
java.lang.ClassCastException: fxmatcher.FxFormBean
Here's the line in the generated Java file (from the original JSP)where the exception occurred:
fxFormBean = (fxmatcher.FxFormBean)request.getAttribute("fxFormBean");
The weird problem is that I only get the error the first time I load the jsp. If I reload it, everything is fine.
Here are some relevant snippets from the jsp:
<jsp:useBean id="fxFormBean" class="fxmatcher.FxFormBean" scope="request"/>
<%@ page import="java.util.*,java.io.*, java.lang.*" %>
Does any one know why this is happening? I think it has something to do with request.getAttribute returning a null because the bean is not instantiated yet when I call the jsp the first time, but I'm not sure. If this is indeed the case, how can I rewrite my jsp so that this doesn't happen again? Thanks for your help
Sure thing.
Here's the stack trace:
java.lang.ClassCastException: fxmatcher.FxFormBean
at jsp_servlet.__index._jspService(__index.java:90)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2495)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2204)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
relevant snippets of compiled code:
/* compiled from JSP: /index.jsp
* This code was automatically generated at 4:12:26 PM on Aug 27, 2003
* by weblogic.servlet.jsp.Jsp2Java -- do not edit.
javax.servlet.http.HttpSession session = request.getSession(true);
try { // error page try block
fxmatcher.FxFormBean fxFormBean = null; //[ /index.jsp; Line: 1]
fxFormBean = (fxmatcher.FxFormBean)session.getAttribute("fxFormBean"); //[ /
index.jsp; Line: 1]
if (fxFormBean == null) { // begin 'fxFormBean' instantiation block... //[ /
index.jsp; Line: 1]
synchronized (session) { //[ /index.jsp; Line: 1]
fxFormBean = (fxmatcher.FxFormBean)session.getAttribute("fxFormBean"
); //[ /index.jsp; Line: 1]
if (fxFormBean == null) { // begin 'fxFormBean' synchronized instant
iation block... //[ /index.jsp; Line: 1]
fxFormBean = new fxmatcher.FxFormBean(); //[ /index.jsp; Line: 1
session.setAttribute("fxFormBean", fxFormBean); //[ /index.jsp;
Line: 1]
} // end synchronized bean instantiation block... //[ /index.jsp; Li
ne: 1]
} // end synchronized bean scope block... //[ /index.jsp; Line: 1]
} // end bean instantiation block... //[ /index.jsp; Line: 1]
out.print("\r\n");
Similar Messages
-
Java.lang.ClassCastException in JSP
Hi All,
We are facing "java.lang.ClassCastException" in JSP page. Below are JSP code, printStackTrace and compiled JSP (from Application Server) file.
We are using Struts 1.2.7, JDK 1.4.2 and Oracle 10g OC4J.
JSP Code:
<nested:iterate property="coverage">
<tr>
<td class="text" align="left" valign="top" width="198" height="2">
<html:hidden name="coverage" property="coverageType" indexed="true"/>
<bean:write name="coverage" property="coverageDescription"/>
</nested:iterate>
printStackTrace:
08/03/26 15:48:07 java.lang.ClassCastException
08/03/26 15:48:07 at jsp.quickquote._Coverages._jspService(_Coverages.java:244)
08/03/26 15:48:07 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:569)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:305)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
08/03/26 15:48:07 at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
08/03/26 15:48:07 at jsp.template._mainLayout._jspService(_mainLayout.java:93)
08/03/26 15:48:07 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
08/03/26 15:48:07 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
08/03/26 15:48:07 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
08/03/26 15:48:07 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
08/03/26 15:48:07 at java.lang.Thread.run(Thread.java:534)
Error is coming in compiled JSP:
org.apache.struts.taglib.bean.WriteTag __jsp_taghandler_12=(org.apache.struts.taglib.bean.WriteTag)OracleJspRuntime.getTagHandler(pageContext,org.apache.struts.taglib.bean.WriteTag.class,"org.apache.struts.taglib.bean.WriteTag name property");
In Struts Action we have used below code
CoverageModel[] cs = (CoverageModel[])coverageCol.toArray(new CoverageModel[0]);
f.set("coverage", cs);
We are facing above exception after 6/8 hours of Application restart. . Some time we not facing above exception till 48hrs.
5 users accessing application day time.
e.g.
If we restart server @ 1 PM then try to login with new browser session at 7 PM or 9 PM, we are facing "java.lang.ClassCastException" on JSP page.
If we restart Applcation Server then code is working fine. After restart, we not get null pointer class cast exception for next 6/8 hour.
Please let me know if anybody has any suggestion/solution.
Thanks and Regards,
KailasHi All,
We are facing "java.lang.ClassCastException" in JSP page. Below are JSP code, printStackTrace and compiled JSP (from Application Server) file.
We are using Struts 1.2.7, JDK 1.4.2 and Oracle 10g OC4J.
JSP Code:
<nested:iterate property="coverage">
<tr>
<td class="text" align="left" valign="top" width="198" height="2">
<html:hidden name="coverage" property="coverageType" indexed="true"/>
<bean:write name="coverage" property="coverageDescription"/>
</nested:iterate>
printStackTrace:
08/03/26 15:48:07 java.lang.ClassCastException
08/03/26 15:48:07 at jsp.quickquote._Coverages._jspService(_Coverages.java:244)
08/03/26 15:48:07 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:569)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:305)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
08/03/26 15:48:07 at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesUtilImpl.doInclude(TilesUtilImpl.java:99)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesUtil.doInclude(TilesUtil.java:135)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag.doInclude(InsertTag.java:760)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag$InsertHandler.doEndTag(InsertTag.java:892)
08/03/26 15:48:07 at org.apache.struts.taglib.tiles.InsertTag.doEndTag(InsertTag.java:462)
08/03/26 15:48:07 at jsp.template._mainLayout._jspService(_mainLayout.java:93)
08/03/26 15:48:07 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
08/03/26 15:48:07 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processTilesDefinition(TilesRequestProcessor.java:239)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:302)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1063)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:263)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:386)
08/03/26 15:48:07 at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:318)
08/03/26 15:48:07 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:229)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
08/03/26 15:48:07 at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
08/03/26 15:48:07 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
08/03/26 15:48:07 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
08/03/26 15:48:07 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
08/03/26 15:48:07 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
08/03/26 15:48:07 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
08/03/26 15:48:07 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
08/03/26 15:48:07 at java.lang.Thread.run(Thread.java:534)
Error is coming in compiled JSP:
org.apache.struts.taglib.bean.WriteTag __jsp_taghandler_12=(org.apache.struts.taglib.bean.WriteTag)OracleJspRuntime.getTagHandler(pageContext,org.apache.struts.taglib.bean.WriteTag.class,"org.apache.struts.taglib.bean.WriteTag name property");
In Struts Action we have used below code
CoverageModel[] cs = (CoverageModel[])coverageCol.toArray(new CoverageModel[0]);
f.set("coverage", cs);
We are facing above exception after 6/8 hours of Application restart. . Some time we not facing above exception till 48hrs.
5 users accessing application day time.
e.g.
If we restart server @ 1 PM then try to login with new browser session at 7 PM or 9 PM, we are facing "java.lang.ClassCastException" on JSP page.
If we restart Applcation Server then code is working fine. After restart, we not get null pointer class cast exception for next 6/8 hour.
Please let me know if anybody has any suggestion/solution.
Thanks and Regards,
Kailas -
ERROR:JAVA.LANG.CLASSCASTEXCEPTION WITH JDEVELOPER 10.0.1.3
I´m trying to use JSTL functions but I have the error
"Error:java.lang.ClassCastException with JDeveloper 10.0.1.3".
When I make or rebuild the code I have the error.
The test <c:when test="${fn:length(P_LIGACOES) > 0}" > has error. I´ve been
used others functions and the error is the same.
Please, see JSP code as follows:
<%@ page import="java.text.DateFormat"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="java.text.NumberFormat"%>
<%@ page import="com.celesc.tf.BilheteTelefonico"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Ligações Telefônicas</title>
<style type="text/css">
Body{
background-image: url(images/fdo.jpg);
background-repeat: no-repeat;
background-color: #FFFFFF;
</style>
<link href="css/ligtel.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1 align=center> </h1>
<h1 align=center> </h1>
<c:choose>
<c:when test="${!empty mensagem}">
<h1 align=center>
<img src="images/erro.jpg"><font size="5" face="Verdana, Arial, Helvetica,
sans-serif"><c:out value="${mensagem}"/></font></h1>
</c:when>
<c:otherwise>
<%
Vector ligacoes = (Vector) request.getAttribute("P_LIGACOES");
SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy
HH:mm:ss");
double totalligacoes = 0;
NumberFormat preco = NumberFormat.getCurrencyInstance();
%>
<c:choose>
<c:when test="${fn:length(P_LIGACOES) > 0}" >
<h1 align=center><font size="5" face="Verdana, Arial, Helvetica,
sans-serif">Nenhuma ligação Realizada</font></h1>
</c:when>
<c:otherwise>
<h1 align=center><font size="5" face="Verdana, Arial, Helvetica,
sans-serif">Relação das Ligações</font></h1>
<table class="table-normal" width="70%" align="center">
<tr class="table-result">
<td colspan="5"><b><%= ligacoes.size()%> </b> Ligações Realizadas</td>
</tr>
<tr class="table-title">
<td>Fone Chamado</td>
<td>Ramal</td>
<td>Data</td>
<td>Duração</td>
<td>Custo(R$)</td>
</tr>
<c:forEach items="${P_LIGACOES}" var="bilhete">
<tr class="table-content">
<td><c:out value="${bilhete.numeroChamado}"/></td>
<td><c:out value="${bilhete.ramalOrigem}"/></td>
<td><c:out value="${bilhete.dataLigacao}"/></td>
<td><c:out value="${bilhete.duracao}"/></td>
<!--<td><c:out value="${bilhete.custo}"/></td>-->
<td><c:out value="${bilhete.custo}"/></td>
<c:set var="totalligacoes" value="${totalligacoes +
bilhete.custo}"/>
</tr>
</c:forEach>
<tr class="table-result">
<td colspan="4" align="right"><B>Total</B></td>
<!-- <td ><B><%= preco.format(totalligacoes)%></B></td> -->
<td><B><c:out value="${totalligacoes}" /></B></td>
</tr>
</table>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</body>
</html>Hi,
Please make sure that there is no other version of *"net.nrj.alf.DimensionLabel"* class present in any other Class Loader
There are various kind of Class Loaders : PreMordial Class Loader, BootStrap ClassLoader, System Class Loader (WebLogic ClassLoader), Application ClassLoader, Module Class Loader....
net.nrj.service.SearchServiceProcessor java.lang.ClassCastException: net.nrj.alf.DimensionLabel java.lang.ClassCastException: net.nrj.alf.DimensionLabel If your code is working fine in WLS9.2 it means in WLS10.3.3 the same class is getting loaded from different Class Loaders...In order to find out which classLoader is being used to load that class please do the following:
<b><font color=maroon>
Class dimentionLevel=Class.forName("net.nrj.alf.DimensionLabel")
ClassLoader cl=dimentionLevel.getClassLoader();
System.out.println("\n\n\t DimentionLevel is loaded from ClassLoader: "+cl);
</font></b>
Above 3 Lines of code you need to write for "net.nrj.service.SearchServiceProcessor" class as well...Because i suspect that these two classes are getting loaded from two different class Loaders.
If the Application Code is 100% correct The Main reason of ClassCastException is Classes are getting Loaded from two Different Class Loaders. You can also look at the Filtering ClassLoader Feature of WebLogic to Tell WebLogic to Load some Classes from a Specific ClassLoaders...As described Here .*http://middlewaremagic.com/weblogic/?page_id=192*
Thanks
Jay SenSharma
http://middlewaremagic.com/weblogic/?page_id=2261 (Middleware magic Is Here) -
SQL query with JSP and WML-parameters
Hey,
Could you help me?
I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
/*parameter sending from card 1 to card help*/
out.println("<go href='#helpcard'>");
out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
/*parameter read with WML in card help */
<p>Valitse kurssi.
$valittukurssi</p>
/'parameter read with JSP by generating WML with JSP*/
out.println("<p>$valittukurssi</p>");
/* SQL query with JSP */
ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
Thanks,
RampeYou're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
>
/*parameter sending from card 1 to card help*/
out.println("<go href='#helpcard'>");
out.println("<setvar name='valittukurssi'
value='$(valittukurssi)'/>");
Above you set a var that will work on the phone, not in JSP.
/*parameter read with WML in card help */
<p>Valitse kurssi.
$valittukurssi</p>
Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
/'parameter read with JSP by generating WML with
JSP*/
out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
<p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
out.println("<go href='#helpcard'>");
String some_name = "valittukurssi";
out.println("<setvar name='"+some_name+"'
value='$("+some_name+")'/>");
//note that you may have to escape the ( and ) with a \
//so we displayed the variable above into the WML page, now we can use it in the SQL query:
/* SQL query with JSP */
ResultSet uudettulokset =
uusilause.executeQuery("select * from kurssi where
lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
Frank Krul
Got Node? -
Create a new directory in server with JSP
Hi,
How can I create a directory in server with JSP.
File dir = new File("a");
dir.mkdir();
does not work. what do I do?
best regards,Hi
Check the following things.
1. What is the path where you are creating the directory.
2. Do you permissions to create file in that directory.
3. do a delete on that filename if that exists just to be sure. isdeleted = filedir.delete(). Check the boolean flag isdeleted too.
Thanx and Regards
Aruneesh -
Running other server-side applications with JSP
Hi,
I'd like to know, if is possible run with JSP (Servlet, or JavaBean) other application, which support COM. I used something like this in JavaScript:
application=new ActiveXObject("excel.application");
and I had all possibilities of its API. I'd like to use excel as data source for user-friendly data input.
Thanks for all suggestionsHi,
I don't realy understand your question.
If your javascript work using activeX, this code is executed on the client side (like the excel application and the excel file).
You can, with a JSP, generate the html page that contain the script.
Where is the problem ? -
Displaying an Image in an Excel Spreadsheet with JSP - URGENT
Hi Peoples
I can transfer the table I am using in to excel with JSP by doing:
<%@ page contentType ="application/vnd.ms-excel" %>
this works fine, though I have an image that sits within the table that I want to be displayed as well.
Can this be done?? If so how???
ThanksTry to insert the image into sheet from it's URL not from it's local file path
Best regards -
A problem in RMI with JSP..pls help
RMI with Java is working fine,but...
1. I am facing a problem when i use RMI with JSP..its throwing an exception during "Naming.lookup"..here is my code snippet:
// i have stored the ServerInf and other classes in a package and i have imported it in the jsp code....object ref is getting created but lookup is throwing an exception...thoguh RMI registry is working(started)
<%
try {
ServerInf ref = (ServerInf)Naming.lookup("rmi://localhost:1098/Server_bind");
catch (Exception ex) {
ex.printStackTrace();
%>
Pls tel me the cause.
2. If i try to use RMI with Servlet and JSP, then wen the JSP runs then, it simply calls the servlet file and displayes a lonk to it instead of executing the servlet class. pls help me with this too...below is the invoking statement:
<form method=post action='http://localhost:8080/servlet/MyRMIservlet'>
hello <input type=submit value=submit>And the exception and error message is.....
-
How can I create a Login-page with jsp???
Hello,
I have to create a page with JSP code on the Netweaver Developer Studio.
But I do not know how I do it.
Can anyone tell me what to write in the portalapp.xml?
An example would be very helpful.
Thank you
GreetingsAs you can see in the example:
The portalapp.xml file (deployment descriptor) provides configuration information for your application, and defines the components and services in your application. For each component and service, you specify the implementing Java class and configuration information.
For more information on the format of the portalapp.xml, see Deployment Descriptor (portalapp.xml).
<application>
<application-config>
<property name="SharingReference" value="com.sap.portal.navigation.service, com.sap.portal.navigation.api_mimeservice, com.sap.portal.navigation.helperservice"/>
<property name="Vendor" value="MY_COMPANY"/>
<property name="SecurityArea" value="PERMISSION"/>
</application-config>
<components>
<component name="SimpleNavigationExample">
<component-config>
<property name="ClassName" value="MY_CLASS"/>
<property name="SecurityZone" value="no_safety"/>
</component-config>
<component-profile/>
</component>
</components>
<services/>
</application>
You can only update in this example, your class name and other details:
<property name="Vendor" value="sap.com"/>
<property name="SecurityArea" value="MyCompany"/>
<property name="ClassName" value="LOGINCLASS"/>
<property name="SecurityZone" value="no_safety"/>
Modify this portalapp.xml file as follows:
1. NAVIGATION SERVICE, so you must add references to the following portal applications that define these services:
com.sap.portal.navigation.service
com.sap.portal.navigation.api_mimeservice
com.sap.portal.navigation.helperservice
2. In the <application-config> section, create the following properties that help to define the security zone for all components and services in this application:
○ Vendor: String identifying the company or organization that provided the application, for example, sap.com.
○ SecurityArea: String identifying the security area for the application, for example, NetWeaver.portal.
3. In the <component-config> section for the mySiteMap component, create the property SecurityZone to define the specific security zone for the component.
For Permission, check this document:
http://help.sap.com/saphelp_nw04s/helpdata/en/44/489e2df5ee4e35e10000000a1553f6/frameset.htm -
Help me!! How to use JavaScript with JSP ??
I am using JDeveloper and I created a screen in JSP which uses a bean for database connectivity and retriving info onto the page.
The page has a ListBox where list items are populated from the database.My requirement is
whenever the list is changed the page shuold be refreshed with the selected item info.
I tried to use 'JavaScript' for triggering the event with 'onChange' event of the ListBox.But the event is not getting invoked. I think JavaScript is not working with JSP.
Please help me with how to Use javaScript with JSP or any other alternative where I can meet my requirement.
I have one more question...I have gone through the JSP samples in OTN and I am trying do download the sample 'Travel servlet' which show list of countries...etc
I have also gone through the 'readme' but I don't know how to extract .jar file.
I would be great if you could help me in this.
Thanks!!
Geeta
nullWe have a similar need. We have used Cold Fusion to display data from Our Oracle Database. We have a simple SElect Box in HTML populated with the oracle data. When someone selects say the State of Pennsylvania. then we have an On change event that runs a Javascript to go get all the cities in Pennsylvania.
Proble we are having is that inorder for the Javascript to work , we currently have to send all the valid data.
Do you know of any way to dynamically query the the Oracle database in Javascript -
Hi everyone
I relly do need some help...
I have an Oracle Database and I need to:
1. View my results (of any request) in an excel spreadsheet using JSP (I think this part is the easiest...)
2. And that is my real problem: Use an excel spreadsheet to insert values in the database with JSP...
I hope I made it clear because even for me it's really tricky...
Thanks a lot...
YassiThere is a example in Marty Hal;l's book"Core Servlets and JSP pages".
It is static, but the same idea would work coming from a database.
<HTML>
<HEAD>
<TITLE>Comparing Apples and Oranges</TITLE>
</HEAD>
<BODY>
<CENTER>
<H2>Comparing Apples and Oranges</H2>
<%
String format = request.getParameter("format");
if ((format != null) && (format.equals("excel"))) {
response.setContentType("application/vnd.ms-excel");
%>
<TABLE BORDER=1>
<TR><TH></TH><TH>Apples<TH>Oranges
<TR><TH>First Quarter<TD>2307<TD>4706
<TR><TH>Second Quarter<TD>2982<TD>5104
<TR><TH>Third Quarter<TD>3011<TD>5220
<TR><TH>Fourth Quarter<TD>3055<TD>5287
</TABLE>
</CENTER>
</BODY>
</HTML> -
Can you use threads in a web application that uses JSP's plus Servlets and Beans ?
We have a JRUN 3.1 application using JSPs, Servlets and Beans. Shortly after we went live it became apparent that any 2 users using the same object experienced problems as one object was overwriting another. In a panic the problem was solved by whacking SYNCHRONISED on all objects.
Now we want to write another application, are there strategies for using Threads with JSPs?
Would this be part of the webserver configuration or would the application be coded in a certain way ?
Please can you give me a simplistic answer or point me to some documentation that gives a simple overview.
Thanks SteveHi,
You can use thread with jsp, i am sending u a example
package thread;
import java.io.Serializable;
public class TaskBean implements Runnable, Serializable {
private int counter;
private int sum;
private boolean started;
private boolean running;
private int sleep;
public TaskBean() {
counter = 0;
sum = 0;
started = false;
running = false;
sleep = 100;
protected void work() {
try {
Thread.sleep(sleep);
counter++;
sum += counter;
} catch (InterruptedException e) {
setRunning(false);
public synchronized int getPercent() {
return counter;
public synchronized boolean isStarted() {
return started;
public synchronized boolean isCompleted() {
return counter == 100;
public synchronized boolean isRunning() {
return running;
public synchronized void setRunning(boolean running) {
this.running = running;
if (running)
started = true;
public synchronized Object getResult() {
if (isCompleted())
return new Integer(sum);
else
return null;
public void run() {
try {
setRunning(true);
while (isRunning() && !isCompleted())
work();
} finally {
setRunning(false);
And JSP page start.jsp
<% session.removeAttribute("task"); %>
<jsp:useBean id="task" scope="session"
class="thread.TaskBean"/>
<% task.setRunning(true); %>
<% new Thread(task).start(); %>
<jsp:forward page="status.jsp"/>
///////////////// status .jsp
<jsp:useBean id="task" scope="session"
class="thread.TaskBean"/>
<HTML>
<HEAD>
<TITLE>JSP Progress Bar</TITLE>
<% if (task.isRunning()) { %>
<SCRIPT LANGUAGE="JavaScript">
setTimeout("location='status.jsp'", 1000);
</SCRIPT>
<% } %>
</HEAD>
<BODY>
<H1 ALIGN="CENTER">JSP Progress Bar</H1>
<H2 ALIGN="CENTER">
Result: <%= task.getResult() %><BR>
<% int percent = task.getPercent(); %>
<%= percent %>%
</H2>
<TABLE WIDTH="60%" ALIGN="CENTER"
BORDER=1 CELLPADDING=0 CELLSPACING=2>
<TR>
<% for (int i = 10; i <= percent; i += 10) { %>
<TD WIDTH="10%" BGCOLOR="#000080"> </TD>
<% } %>
<% for (int i = 100; i > percent; i -= 10) { %>
<TD WIDTH="10%"> </TD>
<% } %>
</TR>
</TABLE>
<TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD ALIGN="CENTER">
<% if (task.isRunning()) { %>
Running
<% } else { %>
<% if (task.isCompleted()) { %>
Completed
<% } else if (!task.isStarted()) { %>
Not Started
<% } else { %>
Stopped
<% } %>
<% } %>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<BR>
<% if (task.isRunning()) { %>
<FORM METHOD="GET" ACTION="stop.jsp">
<INPUT TYPE="SUBMIT" VALUE="Stop">
</FORM>
<% } else { %>
<FORM METHOD="GET" ACTION="start.jsp">
<INPUT TYPE="SUBMIT" VALUE="Start">
</FORM>
<% } %>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
////////////////////////////// stop.jsp
<jsp:useBean id="task" scope="session"
class="thread.TaskBean"/>
<% task.setRunning(false); %>
<jsp:forward page="status.jsp"/>
deploy it into ur server and run start.jsp
and see whatb happens -
hello friends,
i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
also when i use an additional field other than username the jsp page is showing error.
Please give me the correct method to use java bean with jsp in this circumstance.
thank you.thank you, but i have a problem left. the case is like this.
i got the jsp and bean worked fine when i have a sinle input text field.
but when i added a second text field i recieved the following error.
javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
pls hlp. -
Does anyone know how to create an INSERT statement with JSP using
variables??
I can do the insert if I code the values of the variables in the statement,
but when I try to use variables to do the insert it tries to insert the
variable name and not the value of the variable into the table.
Thanks,
Doug
"Doug Schaible" <[email protected]> wrote in message news:<bicO7.1279268$[email protected]>...
> I can do the insert if I code the values of the variables in the statement,
> but when I try to use variables to do the insert it tries to insert the
> variable name and not the value of the variable into the table.
Doug,
I think you missed the <%= blahblah %> syntax.
Regards
drit
-
Hi guys Pls tell me a way to connect db4 database with jsp and which driver
hi guys
Pls tell me a way to connect db4 database with jsp and
also tell me which driver i have to use
also tell me how to connect with excel sheetstake a look at the follwing links. There, you'll find all what you need :
DB4:
http://www.oracle.com/database/berkeley-db/je/index.html
http://www.oracle.com/technology/products/berkeley-db/je/index.html
http://www.oracle.com/database/berkeley-db/db/index.html
http://www.oracle.com/database/docs/berkeley-db-je-datasheet.pdf
Excel:
http://64.18.163.122/rgagnon/javadetails/java-0516.html
Hope That Helps
Maybe you are looking for
-
Gentlemen: I am trying to install the program Garmin Mobile XT in my PalmZire 72. I have a Adapt AD-350+ Bluetooth GPS receiver. The program initiates the installation, however, I receive the following message: "FATAL ALERT - Emul68KMain.c, line: 438
-
JDBC Communication channel : Error establishing socket
Dear friends, Im using JDBC comm channel. JDBC driver has been insatlled for SQL Server 2000 (SP3) . However for the JDBC comm. channel i get an error "SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.' following par
-
Hey guys, I love Numbers for charts as it looks wayyyyy more professional than Excel. However, there is one thing thats getting frustrating. My charts tend to have very long titles as they are the results of scientific experiments. When I enter a tit
-
I would like to use adobe reader ( activex for IE and plugin for browsers firefox, safari etc.) to load documents and print them using javascript (batch print) from web page hosting it. Is there any way to support it? May be events will tell me when
-
How to email movie clip not as quick time
I made a 20 second video that I am trying to e-mail to a friend. It is 214 mb. When I click on share in iMovie, it compresses the video and makes it a QuickTime video. The QuickTime video looks horrible, grainy, and dark. When I try to attach the ori