?
Solved

Compilation problem when using session data and importing a Java object

Posted on 2003-03-27
11
Medium Priority
?
266 Views
Last Modified: 2010-04-01
Hello,

I'm hoping someone can identify what I'm coding incorrectly on my JSP.

Just to give you a quick idea, I'm collecting some information from a user session, that includes an string ID being converted to an int, an array of String values (pulled out of a submitted multiple select) being placed in a Vector as Integers, and a String for a filename. These values are then to be submitted to a Java class through a method that accepts those three values as parameters.

The package is called ibuilder, the class is called iBuilder, as is the method within it that I'm calling (iBuilder(int, Vector, String)).

I'm suspect my problem is a pretty simple syntax issue, but being relatively new to Java and JSP, I can't figure it out. Here's the code in question. There error can be found below it.

Thanks!

Eschel

--------------------
<%@ page import="java.util.*" %>
<%@ page import="ibuilder.iBuilder" %>
<%-- Core tags--%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%-- Format tags--%>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>

<fmt:parseNumber type="number" integerOnly="true" var="mhIdInt" scope="session">
<c:out value='${sessionScope.mhId}'/>
</fmt:parseNumber>

<jsp:useBean id="ib" class="ibuilder.iBuilder" />

The ID being used is:
<c:out value='${sessionScope.mhIdInt}'/>
<P>
The file into which its data will be placed is:
<c:out value='${sessionScope.extractFile}'/>
<P>
It's associated value/s is/are:
<%
String[] iDIds=request.getParameterValues("miSelectRight");
if (iDIds == null) {
out.println("missing!");
} else {
Vector idItems = new Vector();

for (int i = 0; i < iDIds.length; i++) {
idItems.add(new Integer(idItems));
}
for (Enumeration items = idItems.elements(); items.hasMoreElements(); ) {
out.println((Integer)items.nextElement());
}
}
ib.iBuilder(${sessionScope.mhIdInt},idItems,${sessionScope.extractFile});
%>

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>MI Submit</title>

</head>

<body bgcolor="white">
<P>
<B>Your custom extract has been submitted.</B>
</body>

-------------------------------
The error I'm getting:

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Tomcat-4.1\work\Standalone\localhost\eschel-app\submit_jsp.java:103: ')' expected
[javac] ib.iBuilder(${sessionScope.mhIdInt},idItems,${sessionScope.extractFile});
[javac] ^
[javac] C:\Tomcat-4.1\work\Standalone\localhost\eschel-app\metabase_submit_jsp.java:103: cannot resolve symbol
[javac] symbol : variable $
[javac] location: class org.apache.jsp.metabase_submit_jsp
[javac] ib.iBuilder(${sessionScope.mhIdInt},idItems,${sessionScope.extractFile});
[javac] ^
[javac] 2 errors



at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
0
Comment
Question by:eabhamel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 8218561
>ib.iBuilder(${sessionScope.mhIdInt},idItems,${sessionScope.extractFile});
You can't use EL in scriptlet.
So, for example, instead of
>${sessionScope.extractFile}  use
(String)session.getAttribute("extractFile")
0
 

Author Comment

by:eabhamel
ID: 8218652
Cool, it now makes it past the first item, having changed the line in question from:

ib.iBuilder(${sessionScope.mhIdInt},idItems,${sessionScope.extractFile});

to:

ib.iBuilder(session.getAttribute("mhIdInt"), idItems,(String)session.getAttribute("extractFile"));

But it's now choking on my Vector:

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] C:\Tomcat-4.1\work\Standalone\localhost\eschel-app\metabase_submit_jsp.java:103: cannot resolve symbol
    [javac] symbol  : variable interfaceDetailItems
    [javac] location: class org.apache.jsp.metabase_submit_jsp
    [javac]   interfaceBuilder.interfaceBuilder(session.getAttribute("mtbInterfaceIdInt"),interfaceDetailItems,(String)session.getAttribute("extractFile") );
    [javac]   iBuilder.iBuilder(session.getAttribute("mhIdInt"),idItems,(String)session.getAttribute("extractFile") );
    [javac]                                                     ^
    [javac] 1 error
0
 

Author Comment

by:eabhamel
ID: 8218669
A quick clarification:

The caret is pointing at idItems.

Thanks,

Eschel
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:eabhamel
ID: 8218826
A quick clarification:

The caret is pointing at idItems.

Thanks,

Eschel
0
 
LVL 28

Expert Comment

by:rrz
ID: 8218885
>The caret is pointing at idItems.
Are you sure?
> iBuilder.iBuilder(session.getAttribute("mhIdInt"),  
the method getAttribute returns a Object.
What type of object did you set for "mhIdInt" ?
0
 
LVL 28

Expert Comment

by:rrz
ID: 8218994
Oh,you didn't construct vector correctly either.
<%
String[] iDIds=request.getParameterValues("miSelectRight");
if (iDIds == null) {
out.println("missing!");
} else {
Vector idItems = new Vector();

for (int i = 0; i < iDIds.length; i++) {
idItems.add(new Integer(iDIds[i]));
0
 

Author Comment

by:eabhamel
ID: 8219135
Oops.  When I copied the code in I made a typo, and didn't enter the line in question correctly.

Although I entered:
idItems.add(new Integer(idItems));

It should have been:
idItems.add(new Integer(iDIds[i]));

As you said.  And regarding the pointer, try copying and pasting the error message into an editor with a fixed-width font.  You'll see it pointing to the Vector parameter.

I've also upped the points I'm giving for the help you're providing.

Thanks!

Eschel
0
 
LVL 28

Expert Comment

by:rrz
ID: 8219384
> [javac] C:\Tomcat-4.1\work\Standalone\localhost\eschel-app\metabase_submit_jsp.java:103: cannot resolve symbol
   [javac] symbol  : variable interfaceDetailItems

where is variable interfaceDetailItems  ?
0
 

Author Comment

by:eabhamel
ID: 8219679
Sorry, I'm modifying [most of] the variables to feebly attempt to obscure the business of my script...

Unfortunately, in my rush to get my replies out before I skipped off for lunch, I guess I've added to the confusion.

That error was refering to idItems in our discussion here.

Again, sorry.

Eschel
0
 
LVL 28

Accepted Solution

by:
rrz earned 100 total points
ID: 8219760
So what is the error ?
0
 

Author Comment

by:eabhamel
ID: 8220236
Well, there were a few, but I had someone here take a look at the code in question, and first of all, the Vector wasn't recognized because it was out of scope!  ARGH!  ;)

I moved its declaration to the beginning of the scriplet, so that it'd be recognized outside of the if-else statement.

I could kick myself that it was as simple as I feared.

But thanks for your help.  I'll award you 30 for the time you took, because I do appreciate the help.

Eschel
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
IF you are either unfamiliar with rootkits, or want to know more about them, read on ....
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question