Undefined variable, class, or package name
The following code in the jsp is supposed to display the correct 'Securities' link based on the app_main_frames URL. I am getting an error. Can anyone help?
<% if (parent.app_main_frame.location == ("http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")) { %>
Securities
<% } else { %>
<a href="/cgi-java/Holdings/jsp/SecurityInventoryQuery.jsp?which_search=none&which_category=none
target="app_main_frame">Securities</a>
<% } %>
I am getting the following error:
Generated servlet error:
/opt/JBoss-2.4.4_Tomcat-4.0.1/catalina/work/localhost/cgi-java/common/jsp/NavigationMenu$jsp.java:173:
Undefined variable, class, or package name: parent
if (parent.app_main_frame.location ==
^
("http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")) {
If app_main_frame is a frame in a frameset then you cannot
simply refer to it in a Java scriptlet.
You can refer to it in a JavaScript script, like this:
<script>
if (parent.app_main_frame.location == "http://ccmsun57.ccminvest.com:8080/cgi-java/Allocation/jsp/scenario.jsp?source=init")
document.write("<a href=\"javascript:submit_Form('none')\"target=\"app_main_frame\">Securities</a>");
else
document.write("<a href=\"/cgi-java/Holdings/jsp/SecurityInventoryQuery.jsp?which_search=none&which_category=none\"target=\"app_main_frame">Securities</a>");
</script>
Similar Messages
-
Testing class and package name legality
Hi all. Does the API provide a way of testing if a given class and package name is correct? I have to model a UML diagram tool. Right now, I'm doing it like this:
public boolean canHaveAsNameStrict(String name){
return(!name.startsWith("([0-9])+") && name.matches("([a-zA-Z_0-9])+"));
}for a package, but this may be incmoplete etc. Also, are the brackets ([...]) and the + sign delimeters or part of the match? (I copied this code from an exercise solution, in which they were not mandatory to the solution)Beware - the JLS allows non-ASCII class and package names. You can have a class named "�owyn", for instance.
class CheckPackage {
public static void main(String[] args) {
String pat = "([A-Za-z_$][A-Za-z0-9_$]*\\.)*[A-Za-z_$][A-Za-z0-9_$]*";
System.out.println (args[0].matches (pat));
} -
Not allowed to import classes without package names?
Hi,
I have a few questions on Packages and importing?
1. Is the following true that it is illegal to import classes in the same package as the current class, will this cause a comilation error? If this is the case where in the Java Language specification is this actually written as I could not find it?
2. This has probably been answered by question 1 but if I have 2 classes in the same package and if I import 1 of the classes into the other class, is it illegal to import it by just using the class name and not the package name as well, ie
if the package name is ie.tcd
and the 2 class names are exp1.class and exp2.class, can I do this in class 2
package ie.tcd;
import exp1;
public class exp2 {
3. Is it illegal to import classes that are not explicitly part of any package or must a class be part of a package to be imported. I read somewhere that while this was always illegal it is only after jdk 1.4.2 that this is being enforced? If this is the case where in the Java Language specification is this actually written as I could not find it either?
Thanks very much for any help,
JohnWas just also wondering, 1 other thing, I am looking
at someone elses code they have 2 classes (Class A
and Class B) in the same package (pkg). The person
imports class A into B:
package pkg;
import A;
public class B {
Is this legal code (or was it ever)?Not if A is really in pkg.A. If there is an A in the unnamed package it was legal, or at least it was understood by the compiler, and now it isn't (to both).
Can you import or is there a point in importing a class in the same
package?Only by naming the package in the import statement. If the current and the import statement are in the same package the import is redundant.
If there is a point would you import just be
using the class name (this would be illegal after jdk
1.4) or should you use the whole package name even
though it is in the package anyways?As I understand it you must always use the whole package name in imports. -
I'm novice in Java, but not novice in programming. So, it is not a problem to understand and to write simple samples, but it is still hard to create a good package structure and give good names for classes.
For example now, I started writing simple standalone application, which will be run by cron and will communicate with 2 webservices. I will receive data(reports) from one webservice, and will send this data to another one. From the very beggining, I have a poblem about structure of roject and naming. Is it ok, to make only one class, with name for example ReportApp? Or better create one class for communicating with first service, another - with second, and main class will call methods of this classes? Also package name... I think it is good, when from package you see, that i is service, or xml.util etc. How can I show in package name that it is batch standalone application? Can somebody explain what names for classes and packages he'll use for such task, please.Descriptive names are nice....
For packages, a standard method is a domain name for your company or organization:
com.widgetsRus.service.
com.widgetsRus.ui.
com.widgetsRus.util.
As for class names, just descripe what the class is for. ReportServer, ReportClient, Report (interface), AbstractReport (implements Report), StatusReport (extends AbstractReport), etc...
As for creating a class for this and that, or separate classes, that's a design issue, but typically, it's easier to maintain things if they are kept in smaller classes with related functionality. -
Need Hex Encoder Class and Package Name
Hi,
I have a requirement in which I need to convert an xml (input) into a Hex format (output). I know that there is a class called as BASE64Encoder when you want to encode a data into base64Binary format and this one is present in the sun.misc.BASE64Encoder package. Now my question is do we have some class called as HexEncoder included under some standard package (like sun.misc.HexEncoder)?
Please provide pointers on how to solve this.
Thanks,
Abhishek.Hi,
You get most of the encorders from here http://www.koders.com/java/fid1DEA9207865756960D16FBA292EE6534A47D3BAD.aspx
Regards
Ayyapparaj -
How to omit package names?
Hello all,
I'm new to javadoc and trying to format my classes sames as the
sdk doc. The problem is that in the sdk doc on top of the page
the tree shows the classes with package names, and in the
parameter lists etc. the package names, e.g. for "String",
are not shown. How can I do this? I want to get exactly the
same documentation format as the sdk doc.
With -noqualifier I can not do what I want. I only can get all
classes full qualified or no class at all.
Thanks in advance.
bye
MarcusWe have also addressed this problem in DocFlextor for Javadoc v1.1
by introducing two new template parameters:
(1) Omit package qualifiers started with
(2) Omit all package qualifiers
You may use freeware DocFlextor Doclet:
http://www.filigris.com/downloads/
or look at the whole thing:
http://www.filigris.com/products/docflextor_for_javadoc/
-- Leonid Rudy -
10g Preview: Deep Package Names
It appears that you can't add classes with package names longer than 6 nodes into a 10g project.
I just so happen to have some classes that have a package name which is 7 levels deep. I couldn't add it to my project via the navigator. I played around with it and sure enough was able to add it if package names were 6 nodes or less.
Example:
I couldn't add this class ...
package 1.2.3.4.5.6.7;
public class X {}
But could add this ...
package 1.2.3.4.5.6;
public class X {}
- MattMaybe it has something to do with the directory structure in which your class files are stored?
So, I'm thinking that maybe a directory structure like "C:\Documents and Settings\<user>\Application Data\JDeveloper Work\workarea name\project name\classes\p1\p2\p3\p4\p5\p6\p7" could cause more of a problem than "C:\JDeveloper Work\workarea name\project name\classes\p1\p2\p3\p4\p5\p6\p7".. -
Undefined variable or class name
I am trying to call a java class to another class but gets the error: "Undefined variable or class name"
Both my java files are in the same directory and I am able to compile only one of the program. Wondering what am I missing?
The source code is:
ServletUtilities.java: (I am able to compile)
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletUtilities {
public static final String DOCTYPE =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">";
public static String headWithTitle(String title) {
return(DOCTYPE + "\n" +
"<HTML>\n" +
"<head><title>" + title + "</title></head>\n");
HelloWWW3.java (getting error when compile)
public class HelloWWW3 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println(ServletUtilities.headWithTitle("Hello WWW") +
"<body>\n" +
"<h1>Hello WWW</h1>\n" +
"</body></html>");I tried and I got these errors:
C:\java servlets\HelloWWW3\src>javac -classpath . HelloWWW3.java
HelloWWW3.java:4: Package javax.servlet not found in import.
import javax.servlet.*;
^
HelloWWW3.java:5: Package javax.servlet.http not found in import.
import javax.servlet.http.*;
^
HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
oWWW3 not found.
public class HelloWWW3 extends HttpServlet
^
3 errors
Then I moved HelloWWW3.java and ServletUtilities.class file to C:\jakarta-tomcat-3.2.3\lib
This dir has files
JAXP JAR
SERVLET JAR
ANT JAR
PARSER JAR
WEBSER~1 JAR
JASPER JAR
and compiled and got this error
C:\jakarta-tomcat-3.2.3\lib>javac -classpath . HelloWWW3.java
HelloWWW3.java:4: Package javax.servlet not found in import.
import javax.servlet.*;
^
HelloWWW3.java:5: Package javax.servlet.http not found in import.
import javax.servlet.http.*;
^
HelloWWW3.java:7: Superclass coreservlets.HttpServlet of class coreservlets.Hell
oWWW3 not found.
public class HelloWWW3 extends HttpServlet
^
3 errors
Here is what I hava defined for my CLASSPATH
C:\jakarta-tomcat-3.2.3\lib>echo %CLASSPATH%
C:\jakarta-tomcat-3.2.3\lib\servlet.jar;C:\jakarta-tomcat-3.2.3\lib\jasper.jar
------------------------------------------ -
Class name and package name clashing
When i have a class and a package with the same name, I cannot access classes in the package. For example I have 3 classes and 1 package as below
- Test.java
- PackageName.java
+ PackageName // this is a directory
- MyClass.java
Below are the codes of .java files
Test.java
=======
public class Test { PackageName.MyClass a = new PackageName.MyClass ();}
PackageName.java
===============
public class PackageName{ }
MyClass.java
==========
package PackageName; public class MyClass { }
I can compile PackageName.java and MyClass.java but not Test.java. It says
cannot resolve symbol
symbol : class MyClass
location: class PackageName
PackageName.MyClass a = new PackageName.MyClass ();
But if I remove the PackageName.java, I can compile Test.java perfectly. I think when I use PackageName.MyClass, java thinks that I try to access an inner class MyClass of PackageName class, and that does not exists. Is there any way to solve this ambiguation, other than making the package name and class name different? Thank you very much.This works fine: just add an import to Test.java.
import PackageName.MyClass;
public class Test
public static void main(String [] args)
MyClass a = new MyClass();
public class PackageName {}
package PackageName;
public class MyClass {}It's a pretty wacky, useless example, but it works.
Plus I thought inner classes would have a dollar sign in their .class file names. When I compile this:
public class OuterClass
public static void main(String [] args)
OuterClass outer = new OuterClass();
System.out.println(outer);
public String toString() { return "I'm an OuterClass"; }
class InnerClass
public String toString() { return "I'm an InnerClass"; }
}I see two .class files: OuterClass.class and OuterClass$InnerClass.class
Why make up examples like this? It's hard enough writing code, and it's easy to disambiguate for the compiler. -
Package names missing when specifying classes
Hi!
I need to generate Javadoc for some (not all) of the classes in one of the packages. So I specified the class names in the batch file (thanks again, Doug!) instead of specifying the package name. Now only the classes in the package have HTMLs, but the package is missing from overview-tree.html, package-list, index.html and whatever.
Any ideas?
Thanks!Hi Doug:
I used your link, installed 1.4, and now get the following message when I try to generate Javadoc with MIF Doclet:
javadoc: In doclet class com.sun.tools.doclets.mif.MIFDoclet, method start has thrown an exception java.lang.reflect.In
vocationTargetException
java.lang.NoSuchMethodError: com.sun.tools.doclets.DirectoryManager.createDirectory(Ljava/lang/String;)V
at com.sun.tools.doclets.mif.MIFObjectWriter.genWriter(MIFObjectWriter.java:98)
at com.sun.tools.doclets.mif.MIFObjectWriter.init(MIFObjectWriter.java:76)
at com.sun.tools.doclets.mif.MIFObjectWriter.<init>(MIFObjectWriter.java:50)
at com.sun.tools.doclets.mif.MIFOverviewObjectWriter.<init>(MIFOverviewObjectWriter.java:64)
at com.sun.tools.doclets.mif.MIFConfiguration.initOptions(MIFConfiguration.java:746)
at com.sun.tools.doclets.mif.MIFDoclet.start(MIFDoclet.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
at java.lang.reflect.Method.invoke(Method.java:313)
at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:196)
at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:95)
at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:289)
at com.sun.tools.javadoc.Start.begin(Start.java:114)
When I try to generate "regular" HTML Javadoc (without MIF Doclet), I get the following:
Building tree for all the packages and classes...
javadoc: In doclet class com.sun.tools.doclets.standard.Standard, method start has thrown an exception java.lang.reflec
t.InvocationTargetException
java.lang.ClassCastException: com.sun.tools.javac.v8.code.Type$ErrorType
at com.sun.tools.javadoc.ClassDocImpl.<init>(ClassDocImpl.java:111)
at com.sun.tools.javadoc.ClassDocImpl.<init>(ClassDocImpl.java:134)
at com.sun.tools.javadoc.DocEnv.getClassDoc(DocEnv.java:388)
at com.sun.tools.javadoc.ClassDocImpl.superclass(ClassDocImpl.java:353)
at com.sun.tools.doclets.ClassTree.processClass(ClassTree.java:139)
at com.sun.tools.doclets.ClassTree.processClass(ClassTree.java:144)
at com.sun.tools.doclets.ClassTree.buildTree(ClassTree.java:108)
at com.sun.tools.doclets.ClassTree.<init>(ClassTree.java:67)
at com.sun.tools.doclets.standard.Standard.startGeneration(Standard.java:105)
at com.sun.tools.doclets.standard.Standard.start(Standard.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:42)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:28)
at java.lang.reflect.Method.invoke(Method.java:313)
at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:196)
at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:95)
at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:289)
at com.sun.tools.javadoc.Start.begin(Start.java:114)
at com.sun.tools.javadoc.Main.execute(Main.java:44)
at com.sun.tools.javadoc.Main.main(Main.java:34)
In both cases, nothing is generated....
What am I doing wrong?
Thanks
Benzi -
How to change the package name for a msg class
Can anybody tell me how to change the package name for a message class.
and how will it effect in the rerport?
thanks in advance
kp>>and how will it effect in the report?
You wouldn't see any direct effect on the Report.. But if you transport the report to QA & leave the Message class in Dev, it might result in syntax issues & you will not be able to execute the report. Just ensure that both of them get transported to QA & you will be fine.
~Suresh -
Deploy java stored proc. publishes java class names without package name
Hi to All,
Using JDevStudio 10132 I've created a 'Loadjava and Java Stored Procedure' deployment profile for my project. I've added my static method to the deplyment profile, but it generates script without java packege name, only pure class name.
For example it executes: ...
CREATE OR REPLACE PROCEDURE Procedure1(p1 IN VARCHAR2) AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'CryptoHelper.Procedure1(java.lang.String)';
instead of
CREATE OR REPLACE PROCEDURE Procedure1(p1 IN VARCHAR2) AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'mypackege.xxx.yyy.CryptoHelper.Procedure1(java.lang.String)';
The CryproHelper class is definitely in mypackage.xxx.yyy package and JDeveloper Application Navigator shows correctly it.
Any ideas?
thx fo answersHi,
I've just been doing this on 10133 and found exactly the same thing. It's an easy fix to edit the package body - but it's rather annoying to have to manually do something that should just work.
Steve
*Hand editing the .deploy file to add in the package name works.
Message was edited by:
spilgrim -
Where is the Package Name and Class Name for Android to Facebook SSO?
Where is the Package Name and Class Name for Android to Facebook SSO?
I am trying to fill these fields http://developers.facebook.com/docs/mobile/android/build/#ref for Facebook but i can't figure out what to place in Android Package Name and Andorid Class Name,
same thing for the Android Key Hash, I followed this guide http://www.skoobalon.com/blog/2012/06/13/getting-the-android-key-hash-for-facebook-from-an -air-app/ but I am not sure if it is the right thing to do.
I was thinking maybe the Pakage Name is air.com.myname.myappname (where com.myname.myappname is also the id used in the application.xml) and the Class name is air.com.myname.myappname.MyDocumentClass ?
Is there an official guide somewhere?
Also do you guys know if there is somewhere a library we can use within AIR to do SSO on Facebook from Andorid?For what it's worth, I don't think a WiFi connection would be reliable enough. You wouldn't want your picture to freeze just because a neighbour has turned on their baby monitor. WiFi uses the same frequencies as a myriad of other devices, as well as all your neighbours' WiFi.
-
Package name from classname .class
Is there any way to know the package name of the class from its .class without using the Reflection API's since there we need to instantiate the class with its fully qualified name. Can anybody suggest a method to do it.
javap requires the name of fully qualified class, so
if you are not aware of it, this utility will not
work.
We cannot create an instance of the class, if we donot
know the full name of the class <including the package
name>
Both the above ways I think will not satisfy the
purpose.I'm having a hard time understanding why anyone would want to instantiate a class they don't know anything about, or how anyone could expect to do so. -
Conflit in class name and package name
I have a small doubt. If the class name and the package name are the same in a folder, is there will be any conflict between these while using it. That means suppose a folder named 'animator' contain a package 'a' and a class name 'a'. I got any error in the 'Eclipse' tool that "a collides with a package". Is this can be solved my any change of setting in Eclipse? If then where can i change.? Can anybody help me to solve this issue??
This works fine: just add an import to Test.java.
import PackageName.MyClass;
public class Test
public static void main(String [] args)
MyClass a = new MyClass();
public class PackageName {}
package PackageName;
public class MyClass {}It's a pretty wacky, useless example, but it works.
Plus I thought inner classes would have a dollar sign in their .class file names. When I compile this:
public class OuterClass
public static void main(String [] args)
OuterClass outer = new OuterClass();
System.out.println(outer);
public String toString() { return "I'm an OuterClass"; }
class InnerClass
public String toString() { return "I'm an InnerClass"; }
}I see two .class files: OuterClass.class and OuterClass$InnerClass.class
Why make up examples like this? It's hard enough writing code, and it's easy to disambiguate for the compiler.
Maybe you are looking for
-
In PubSub, could we create a durable subscriber, but specify the message selector later on? Kind of filter the message received by the subscriber after the subscriber is created? Keep in mind, the message needs to be retained in the topic if the filt
-
Fix variable text (File Name) when importing INDD into INDD
More of a fix request than a new feature: Simply put, the variable text (File Name) shows the file extension when the document is imported into another INDD regardless of the variable text specifications in the originating document. This is unexpecte
-
Hi all, I have a website that uses table. I am trying to setup a template in CSS so I can convert over from table format. Below is my my css and html. I have 3 questions. 1) How do I make it so all three columns stay the same height or expand to be
-
How can I sign my laptop to get into my i tunes store?
Hi - I have a i tunes apple account on my desktop. How do I sign in on my laptop so I can watch movies on my TV via my laptop? Ron
-
Module pool screen modification
Hi, I have developed a screen. In that, the listbox gets filled up with some values for eg. customer. after user selects the customer from the listbox, the label field should get the customer name after pressing enter key. how to do it? rgrds Madhuri