May be I did not understand the meaning and usage of attribute "session" in page directive. My understanding is if session=false, in page directive, then the JSP page will not participate in the session. However, I have my welcomepage as below:
I have started working on a little project in my free time. It is just a simple text rpg that runs in a counsel window. I have 5 files each file contains 1 class.
public class SomnusCharacter { private String gender = ""; private int age = 0; private String race = ""; private int level = 0; private int xp = 0;
[Code] ....
The chain of events right now is:
1. MainMenu is run 2. If user inputs n CreateCharactor is run 3. User inputs name, age, ect in SomnusCharacter object made in CreateCharacter 4. Intro (just rough demo for testing purposes) is run 5. If user inputs m Menu is run 6. Menu calls and prints out all the information from the object made in CreateCharacter
Step 6 is where I am having my problems. How can I reference (lets say the SomnusCharacter object made is called player) player from my Menu class? I know that if I made a new character that it would just create another SomunsCharacter object with the default values again.
I have a situation where I have 2 classes and an array of objects which are causing me trouble.
The object type is one I have created - it is made from a class which is neither of the 2 classes I previously mentioned.
The array is created and occupied in Class1 and the problem arises when I try to reference one of the element from Class2.
At first I forgot the the array would be local to Class1.main so I made the array a global variable using:
Java Code: public MyObjectType[] myArray; mh_sh_highlight_all('java'); Then I tried accessing an element (2) from Class2 using:
Java Code: Class1.myArray[2] mh_sh_highlight_all('java'); However I get errors saying that I can't access the static variable from a non-static context.
I understand a little bit about static and non-static objects/methods but don't know how to fix this. Do I need to include "static" in the array declaration?
When does HTTP Session object is created in web application. Suppose I have a website. Home page of website is HTTP page which contains details of company and link to Login page.
Consider below mentioned user journey as scenario:
a. user arrives at home page of website b. user click on Login page c. user fill in login details on login page and click on Submit d. user is successfully authenticated and authorized from back end e. User specific page is shown f. user click on logout link g. user is successfully logged out from website h. user is redirected to home page i. user closes browser
In the above mentioned user journey,
a. at which step does HTTP session starts (means at which steps does HTTP Session object is created ? ) b. at which step does HTTP session ends ?
In case required, assume tech stack to be Java 7, Servlet 2.5, JSP, Tomcat 7, Apache web server (for static web contents).....
My dynamic web project has a java class that captures a session variable with the following code.
HttpSession LoginSession = request.getSession(); String VAR = LoginSession.getAttribute("myVar").toString(); //This is the row 127
If i test the app in local (Mac + Java 1.8 + Tomcat 8) all works. In my remote cloud server (Ubuntu 14.10 + Java 1.8 + Tomcat 8) all works, except this class, that has this code. I copy the complete error here. Note that the row 127 of the error message is the second row of the previous code; and, if i comment this row with // and assign a fix variable all works. So, the problem is that 127^ row.
14-Dec-2014 08:15:23.923 SEVERE [http-nio-8080-exec-14] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [srvNavigation.SrvPT] in context with path [/myapp] threw exception java.lang.NullPointerException at srvNavigation.SrvPT.doGet(SrvPT.java:127) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
how it is decided which class will implement a session listener interface? Which class will implement HttpSessionListener? Which one will implement HttpSessionActivationListener, HttpSessionBindingListener or HttpSessionAttributeListener?
In my case my managed bean is View Scoped and it supports a UI page which has multiple forms and each form is submitted as AJAX POST request.
As per the statndard, setting restriction to 5 should create 5 views and after that based on LRU algorithm the oldest views should get deleted if 6th views is created.
Therefore any action on the oldest view will throw the ViewExpiredException and i simply redirect the user to view expired page.
1) When i set the restriction to 5 views, i open 4 tabs with 3 forms each. 2) I submit the 3 forms on first tab everything works fine. 3) As soon as I go to 2nd tab and submit the first form thr, i get view expired exception 4) It seems I am exceeding the number of views I mentioned in web.xml
I want to know :
1) Does every AJAX POST submit itself creates a view ? 2) How I can count the number of views created in a session ? 3)Can i force expiry of a view in JSF 2.0.2 while the session is still alive ? 4) Normally JSF 2.0.2 session cachces the views. Lets assume session is alive the entire day but a view was created in morning at 9:00 AM and is not used again the entire day. Assuming that session doesn't reaches the max number of views it can save in entire day, will the view created in morning expire on its own after certain interval of time ? If not , can we still force its expiry while keeping the session alive ?
How do you declare methods for a class within the class whilst objects of the class are declared else where?
Say for instance, I have a main class Wall, and another class called Clock, and because they are both GUI based, I want to put a Clock on the Wall, so I have declared an instance object of Clock in the Wall class (Wall extends JFrame, and Clock extends JPanel).
I now want to have methods such as setClock, resetClock in the Clock class, but im having trouble in being able to refer to the Clock object thats been declared in the Wall class.
Is this possible? Or am I trying to do something thats not possible? Or maybe I've missed something really obvious?
Regarding the lifecycle of servlet , in headfirst servlet i can find :
You normally will NOT override the service() method, so the one from HttpServlet will run. The service() method figures out which HTTP method (GET, POST, etc.) is in the request, and invokes the matching doGet() or doPost() method. The doGet() and doPost() inside HttpServlet don’t do anything, so you have to override one or both. This thread dies (or is put back in a Container-managed pool) when service() completes.
How can I call the doGet method of the subclass from the superclass. i am not getting this .
I have a quick polymorphism question. I have a parent class and a sub class that extends the parent class. I then declare an array of parent class but instantiate an index to the sub class using polymorphism. Do I have to have all the same methods in the child class that I do in the parent class? Here is an example of what I mean.
public class ParentClass { public ParentClass(....){ } public String doSomething(){ } } public class ChildClass extends ParentClass { public ChildClass(....)
[Code] ....
Is polymorphism similar to interfaces where the child class needs all the same methods?
I want to know is there any way we can call parent class method using child class object without using super keyword in class B in the following program like we can do in c++ by using scoop resolution operator
class A{ public void hello(){ System.out.println("hello"); } } class B extends A{ public void hello(){ //super.hello(); System.out.println("hello1");
i want to write a class in such a way that i should get the current execution time of another class which is running. I searched in net but it shows only how to calculate the time duration of the current class which is running. But as per my way, i need the execution time of one class from another class. How to do this ?
I am working on a program that simulates a bug moving along a horizontal line, My code works correctly when I test it in it's own class but when I tried testing my constructor and methods in a test class I received an error saying, "package stinkBug does not exist" on lines with my methods. However, stinkbug is not a package.
Java Code:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */
How to create object for "class B" and call the "function_B" from other different class D where class D has no connection with class A? Here is my program.
public class A(){ void print(){} } class B{ void function_B(){} } class C{ void function_C(){} }
Here, A, B, C are in the same package. But class D is in different package.
I am a beginner here at JAVA and I am trying to program a Gratuity Calculator using both interface class and object class but it keeps on compiling with errors saying "cannot find symbol".I tried everything to fix it but it just keeps on stating symbol.
[CODE] public class GratuityCalculator extends JFrame { /* declarations */
// color objects Color black = new Color(0, 0, 0); Color white = new Color(255, 255, 255); Color light_gray = new Color(192, 192, 192);
I was doing coding exercise from a book ('OCP Java SE 6 - Practice Exams' by Kathy Sierra and Bert Bates). I came to a question that told to demonstrate the difference between 'default' and 'protected' access rules by creating/making a directory structure and putting a couple of classes in different packages.
For this, I made a total of four classes, out of which, three classes are-Car, TestingCars, CarDimensions. (The fourth is not yet used in testing code till now, so, I am giving only the other three classes.) Their coding is given below.
Out of these classes, the classes- TestingCars and Car - are in a directory (say, FolderName). And, the class- CarDimensions is in FolderName's sub-folder.
The class 'CarDimensions' is public (and its components too are public). And, I am testing all the classes from the class- 'TestingCars'. But, this class (TestingCars) is not able to find the public class- 'CarDimensions' which is in its sub-folder and gives two 'Cannot find symbol' errors citing the class-CarDimensions. Also, If all three classes are put in one single directory, the programs work, without any error.
Coding: Class TestingCars:class TestingCars { public static void main(String[] args) { Car c = new Car(); c.setType("FourWheeler");
[Code]....
I could not find why the public class- CarDimensions- is not getting found by the TestingCars class.