Using Parameterized Constructor In Servlet - What Happens In Deployment Time
May 2, 2014If i used parameterized constructor in servlet what happens in deployment time?
View RepliesIf i used parameterized constructor in servlet what happens in deployment time?
View RepliesI have been trying to find all day long a way to secure my .ear file from modifications made by third parties... My product is packaged as an .ear file which i send for deployment to other administrators. What i am looking for is a way to "sign" my version of .ear versus the deployed version of .ear to be sure that no modification has been made to my code...
View Replies View RelatedI have a button in jsp, when the onclick event is fired, it will send the request to someaction.do to generate a report and display that report in a new window.
After clicking the button to generate the report, in the business class a sql query is getting executed.
If the query result has less data, then I don't have any problem, I could view my report page.
If the query result has more data, then the query takes at least 5-6mins to complete. However, before the query completes its execution, the same request is automatically invoked again. Due to this the report is not getting generated because [...of the multiple requests?], the browser shows an Internet Explorer error and ends up at a blank page.
No exception is thrown and the only place I could find the place of query execution it stops and starts as a new request from web.xml with Servlet Filters, Action.
Note: For a single .do request, the request is getting repeated for 3 times. Overlapping of request also takes place.
There is a sentence in JLS 7 which I can't figure it out. It says :
A cast from a type S to a parameterized type T is unchecked unless at least one of the following conditions holds:
-S <: T
-All of the type arguments (§4.5.1) of T are unbounded wildcards
-T <: S and S has no subtype X other than T where the type arguments of X are not contained in the type arguments of T.
Condition one and two I got it. But the number three is really bugging me. I write some code in order to try to understand it.
class G<X>{}
class D<T,U> extends G<T>{}
G<String> g = new G<>();
D<String, Integer> dd = (D<String, Integer>) g;
In Eclipse I got no warning but it shouldn't give one ?
Because g has others subtypes than D<String, Integer> (e.g. D<String, List> , D<String, G>)
Am I missing something about the contained type arguments ?
I have set up a project in Eclipse 3.1 and am using java 5.0 compiler.
Here's my folder structure in Eclipse
Java Code:
DFSRemoteClientTestClient.java mh_sh_highlight_all('java');
DFS is the project in Eclipse
And this is how it looks my java class
Java Code:
package RemoteClient;
import java.util.*;
// other imports
public class TestClient {
public static void main(String [] args) throws ServiceInvocationException {
// business logic here ....
}
} mh_sh_highlight_all('java');
So, basically, my java class is just a simple class with a main function.
Now when I build my project, using Project->Clean...
Then I get this as an error at the very first line where i specify the package
This is the error:
Java Code: The type Class is not generic; it cannot be parameterized with arguments <T> mh_sh_highlight_all('java');
What's this error and why am I getting this.
I have implemented a deployment rule set for our JRE enterprise deployments and it is working fine. We are currently deploying JRE version 1.8.0_25. I have stumbled upon a Java App (a webcam) on an internet site that I cannot get to run with the deployment rule set.
The rule set works with other java apps, but it’s as though it is ignored for this one. The rule set section in the ruleset.xml with the intention of allowing the webcam to work is as follows:
<rule>
<id location="IP Address of I assume the webcam, address specified in error when launching app" />
<action permission="run" />
</rule>
<rule>
<id location="URL of website hosting the webcam" />
<action permission="run" />
</rule>
I pulled it out of the deployment rule set and added it to the exception list without any luck getting it to work that way. How I can get this app to work with my Deployment Rule Set?
I am trying to deploy a really simple EJB app-client jar to glassfish but keep seeing the following error in regard to my jar file:
The following extensions or libraries are referenced from the manifest of
C:UsersasmithAppDataLocalTempClient-18654884305939595801.0.jar
but were not found where indicated:
libRemoteInterfaces-1.0.jar libjavaee-api-7.0.jar ;
ignoring and continuing. My jar is set up as follows:
Client-1.0.jar ->
->META-INF
MANIFEST.MF
application-client.xml
sun-application-client.xml
->com.alan.client
Main.class
[Code] ....
I've tried to indent the jar contents correctly but not sure how to do it!
I am having an issue that I cannot seem to resolve with Ant deployments and my Classpath.
I have a module that is needed to run with Open Wonderland but for some reason when I run this particular module deployment it doesn't recognize part of the classpath.
On my server I have a class called JadeRunner.class and it is included in my classpath. I can verify but running the following code:
public class testClassPath{
public static void main(String args[]){
String classArg = args[0];
try{
Class testClass = Class.forName(classArg);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
I just enter the name of the class as an argument and if I get no errors that it can find the class. This works if I enter it directly from the command line. However with my ant deployment I get a ClassNotFoundException for this class.
I run my ant deployment as root but I use the -E switch so it picks up my environment variables. The ant deployment finds all my other environment variables except this one.
I have some sample outputs:
$ java testClassPath org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner (this give no output, so it finds the class)
$ sudo -E java testClassPath org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner (again no output, so it finds the class)
$ sudo -E ant deploy
This gives ClassNotFoundException: org.jdesktop.wonderland.modules.mas.jade.weblib.JadeRunner
How can we create deployment descriptor for the java projects.
View Replies View RelatedHow do I get java to tell me what it thinks the current deployment configuration properties are? I'm aware of Deployment Configuration File and Properties and see it tells me what the values are, how to set them, etc. But what I want is a way to run java and have it cough up what it's currently using. Something like 'java -display-config-properties' and have it spit out all current values it's using.
View Replies View RelatedI have a signed certificate from Entrust which I used to sign a DeploymentRuleSet.xml file. I placed the DeploymentRuleSet.jar in the proper location C:WindowsSunJavaDeployment, afterward the java control panel's security tab shows a link to "show the active deployment rule set" which did not exist prior to coping the file to the directory. When I click on the link a new window opens and says "Rule Set not found" ....
View Replies View RelatedI am a beginner want to compile servlet with following path
javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java
Problem arises as follows:
javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options
calling a parameterized stored procedure in java jdbc from sql server.The stored procedure goes like this in sql
create proc patientreg
@id int
as
begin
select [patient_id],[Psurname], [pFirstname], [pMiddlename], [reg_date], [DOB], [Sex], [Phone_num], [Addr],[Email],[dbo].[fncomputeage](DOB) from [dbo].[Patient_registration] where [patient_id] = @id
end
please note dbo.fncompute(DOB) is a function
To call it in jdbc it goes like this
try{
String str = "{call patientreg(?)}";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbcdbc:GeneralHospit al");
cstmt = con.prepareCall(str);
cstmt.setInt(1, Integer.parseInt(t.getText()));
[code]....
after doing it this way it throwing an exception: Error:java.sql.SQLException: Parameter 1 is not an OUTPUT parameter.
This is the code that i have used to delete particular String from text file. It works absolutely fine on eclipse and netbeans.. But on deployment(in tomcat) it fails to delete message/rename or delete original file even though all permissions for modifying the files in the folder has been given to all users.
This is my code:
package com.pro.model;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
[Code] ....
How to map a request URL to a url pattern in deployment descriptor. I got all the answers right, but I am not sure if the thought process is correct.
<servlet>
<servlet-name>One</servlet-name>
<servlet-class>foo.DeployTestOne</servlet-class>
</servlet>
<servlet-mapping>
[Code] .....
1) [URL] ....
Container choice: DeployTestOne (matched the *.do extension pattern)
Exact match check: Is there a URL pattern in DD which is exactly = /MapTest/blue.do ? NO.
Directory match check: Is there any URL pattern in DD for directory /MapTest ? NO.
Extension match: Is there a pattern in DD for files with extension .do ? Yes !
Select DeployTestOne !
Question - When doing an Exact match check, does the container look for blue.do in DD or does it look for /MapTest/blue.do ?
2) [URL] ....
Container choice: DeployTestThree (matched the /fooStuff/* directory pattern)
Exact match check: Is there a URL pattern in DD which is exactly = /MapTest/fooStuff/bar/blue.do ? NO.
Directory match check: Is there any URL pattern in DD for directory /MapTest/fooStuff/bar ? Yes !
Go for the url pattern for longest pat, that is, /fooStuff/*
Question - When doing the directory match check, does the Container look for /MapTest/fooStuff/bar/ or just /fooStuff/bar ?
I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)
I need the output time to be the time the class started, plus the length of the class, and displayed in military time.
for example,
Start Time = 0930
Length = 50 minutes
Endtime = 1020
I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say
Start time: 0700
Length = 90 minutes
I get:
Endtime = 90
90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.
Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.
public class calc
{
public static void main(String[] args) {
double hours, minutes, length;
double temp;
int time = 2400;
hours = time / 100;
System.out.println("Hours are: " + hours);
[Code] ....
I have two classes. time_runner is used for testing my code.
This is what I'm using to test my code:
class time_runner
{
public static void main(String str[]) throws IOException {
Time time1 = new Time(14, 56);
System.out.println("time1: " + time1);
System.out.println("convert time1 to standard time: " + time1.convert());
System.out.println("time1: " + time1);
System.out.print("increment time1 five times: ");
time1.increment();
[code]....
The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.
public class Time {
private int hour;
private int minute;
public Time(int h, int m) {
if(h > 1 && h < 23)
hour = h;
[code]....
I was practicing my java skills and came across an exercise in which a non parameter constructor calls a two parameter constructor. I tried a few searches online but they all came back unsuccessful. This is the part I am working on:
public PairOfDice(int val1, int val2) {
// Constructor. Creates a pair of dice that
// are initially showing the values val1 and val2.
die1 = val1; // Assign specified values
die2 = val2; // to the instance variables.
}
public PairOfDice() {
// Constructor that calls two parameter constructor
}
I tried calling the two constructor using the line "this(val1, val2)" but I get an error because val1 and val2 are local variables.
Then I tried to use the same signature: "this(int val1, int val2)" but that didn't work either.
I'm wonder about the issue of constructor for arrays. Let say I have a class tablica, and one component int[] tab. If I get it right until now tab is nothing more than empty reference to some unexisting array?
import java.util.Random;
class tablica{
int[] tab;
tablica (){ // i wish it was constructor
[code]....
Then, I'm trying to build the constructor for class tablica. What can be the parameter of such constructor? Is it fields of array? It is simple forf for basic variable
- I liken values defined in constructor with those global defined in class. But how to do it with array component tab.
If I create array object in main method then how can I use this constructor?
public class TestClass {
public TestClass(String k){System.out.println(k);}
public static void main(String[] args) {
try {
hello();
}
catch(Exception e){System.out.println(e);}
[Code] ....
Explain how to catch block act as constructor with parameter?
Java Code:
package ZooZ;
import java.util.Random;
public class Animal {
int playerOne; <------- Remains 0
int playerTwo; <------- Remains 0
Random random = new Random();
[Code] ....
If you look at the code, I set "playerOne" and "playerTwo", to set them as what was passed in from another class..
In the Animal constructor.
in that constructor the value is 2. But when I use it in the "Bash()" method it is 0 in the console.
Why doesnt the playerOne and playerTwo stay the value it is assigned in the constructor.??
"A constructor cannot be abstract, static, final, native, or synchronized."
I understand on why it can't be all of the above, except "final".
Why can't we have a final constructor, i understand constructors are not inherited, hence no chance/case of overriding etc. But why is it not allowed at all ?
So I am working on a school project and I have 2 classes, class FakeGravity contains all the properites and class BouncyBall is my driver class. For some reason when I try writing
FakeGravity gravity = new FakeGravity( );
I get an error. I am attaching an image of the error, and also attaching the program just in case you need more information. Also I was using blueJ to write the program
dcasarrubias, on 27 October 2014 - 02:44 PM, said:
So I am working on a school project and I have 2 classes, class FakeGravity contains all the properites and class BouncyBall is my driver class. For some reason when I try writing
FakeGravity gravity = new FakeGravity( );
I get an error. I am attaching an image of the error, and also attaching the program just in case you need more information.
The LocalStudent class inherits the Student class. The IDE states an error of "no default constructor in Student class".I understand that if a LocalStudent object is created, the default constructor of its superclass (aka Student class) will be called implicitly.there is no LocalStudent object being created, so why is the default constructor of Student being called ?
The default constructor of LocalStudent is also overloaded by the created no-arg constructor containining subjects = null; . So there is no call to the superclass default constructor from the default constructor of LocalStudent.
public class Student {
private char year1;
public Student(String name, char year){
year1 = year;
}
public char getYear(){
return year1;
[code]...
I am trying to create a user defined Exception. I am using a hard-coded value in the constructor of circle class at the time of object creation.But in the constructor this value becomes 0.
import java.lang.Exception;
import javax.swing.*;
class InvalidRadiusException extends Exception{
private double r;
public InvalidRadiusException(double radius){
r = radius;
[Code] ....
Due to this its always generating InvalidRadiusException even if i am supplying a non-zero non-negative value.
I want to add validation to some of the elements in my constructor.
Person(String idIn, String nameIn, ) {
this.id = idIn;
this.name = nameIn;
}
I want to be able to check that the data for the ID is limited to a certain collection of characters formatted in a certain. For example, I may wish to limit it to 5 lowercase letters or numbers, or a combination of both. How could I do this?