We can have attributes in different scopes in a JSP page. Suppose there is an attribute named 'name' with values in different scopes as below:
request - A
session - B
application - C
page - D
Suppose I print ${name} in a JSP page, then what will be the value printed on the JSP? And, what will be the preference order of attributes search in different scopes?
I am new to Java and I am doing an assignment to identify Class and Attributes from below example. How to identify 7 classes and its attributes from this scenario:
ABC Maps Maker produces electronic maps for global positioning systems. Every map needs to define the latitude and longitude of the centre of the map, together with the length and breadth of the map. A map also has a name, and a set of geographical features.
A geographical feature is something noticeable in a a map; e.g., a hill, or valley. Among the types of features are the following: trace features, track features and tract features.
All features have a name that is displayed on the map next to the feature. A trace feature has a coordinate point to indicate its location relative to the centre of the map. Broadcasting stations, mountain peaks, and transmission towers, are examples of trace features. Every trace feature has a description associated with it.
Examples of track features include roads, railways and rivers. Each track feature has a list of points that define its course, and a line pattern. The line pattern specifies the colour, and the thickness.
Like a track feature, a tract feature also has set of points, except that when drawn on the map, the last point is linked to the first point to enclose a complete region. Additionally, it has a fill pattern which incorporates essentially a colour.
Recall that there is a class, Point, in the java.awt package – this can be used to hold the co-ordinate of a point
MDS don't support all six transaction attributes. MDBs support only REQUIRE or NOT_SUPPORT.... There is no existing transaction to suspend or join when a message is delivered, The two options you have available are REQUIRE if you want a transaction.....
there is no existing transaction when a message is delivered from a queue to an MDB. Why we still need a transaction as it says " REQUIRE if you want a transaction"? When a message is delivered from the queue to the MDB, is this a transaction?
What is the difference between Attributes and Parameters.that is difference between two methods request.getAttribute() and request.getParameter() and why we have this two methods?
I am building an application that has two types of users. While some of the fields (ie: username, email address, password) are the same for both user types, other fields are different for each user type.
Therefore, I would like to split up the process of registering (ie: writing the user info to database) into two parts:
1) registering the common fields among both user types (servlet 1) 2) registering the specific fields based on the user type that is registering (servlet 2a and servlet 2b).
Therefore, once servlet 1 is processed, I wish to forward the request to servlet 2a or 2b depending on what type of user is registering.
I wish to do this since I will have other parts of my application that will make use of servlets 2a and 2b as well. Is this possible to do (redirect request parameters from jsp to servlet and then to another servlet)?
I have to create a new custom tag "imageLabeable" as a div contains a GraphicImage and an OutputLabel (primefaces).
Since I want to make it reusable as much as possible, I tried to write, in cc:interface section, all GraphicImage attributes (id, value, binding etc) and some new (GraphicImage is the main component among the two). But after that I have must associate GraphicImage attributes with the attributes created in cc:interface:
As you can see, if I have a lot of attributes I have to write a lot of association. Furthermore, if I see html rendered code with Firebug or similar, I see all of these associations.
Can I inherit these attributes automatically? Or associate it in easier way?
String name = "James Bond"; Session.setAttribute("name", name);
Why is the attribute name and attribute value the same in all the books I've read. I know one is a string literal and one is an object but must it be the same?
Second thing I'm confused about... let's say I change the servlet code to
String name = "James Bond"; Session.setAttribute("hisname", name); When I try to access it using JSP: ${sessionScope.name}
it works fine. So what is the point of the first argument in Session.setAttribute() ?
The authenticatedUser and menu attributes are gone. I never know when it's going to happen so I can't trace it. Any guesses why those type session objects would die?
I attached an image of what menu object looks like.
I have two different "business objects", and they have multiple attributes in common(around 25 I believe, all of which are simply a String). Basically, these objects are used for documentation purposes on the same file.
The program can choose to update a given Document at any point in time, even if changes haven't been made to existing version. So what I'm trying to do, is check to see if these attributes differ any between the two files(the exisitng copy, and the new request). If so, I'll update...else I simply throw out the request. The workload can be rather intense at times so I don't want to bog down the system anymore then necessary.
Simply pulling down every attribute for each and comparing seems like a lot of overhead, any more efficient way to achieve these results?
I have an issue with variables/attributes scope inside a jsp tag file.
In short, I have a tag with an attribute named "id". If the page using my tag has a variable called "id" (maybe coming from the spring model) and I call my tag WITHOUT specifying the id attribute, inside my tag I still can acces to the "id" attribute that was defined in the page but I don't want this behavior; if the tag is called without the "id" attribute then it should defaults to empty/null.
(...) The id is: ${id} // <- Prints 'X' <my:print /> <- Prints 'X' ! I want it to not print anything in that case <my:print id="Y"/> <- Prints 'Y' (...)
What I want is to have the tag attributes live only in the tag, without having any knowledge of any variable outside of the tag itself. Is it possible?
My current workaround is to remove the "id" attribute, enable dynamic attributes and with a scriptlet search in the dynamic attributes map for the "id" and save it in a variable with a different name (e.g. "__id").
public class BookExamples { String title; String genre; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Hey");
[code]...
Eclipse gives me an error for b1.genre = "hey"; saying "Syntax error on token "genre", VariableDeclaratorId expected after this token". I am learning from a HeadFirst Java book that is all in Java 5.0 version which may be part of the problem.
I have to use the company's login resource, which returns a login page for authentication after a browser/user page request; after successfully authenticated, the session attributes are set in a (remote) valued object (VO) invoked via servlet; then, such values are set in my (local) POJO.
I want to display the current user session attribute (see xChave below) and save it in database. How can I persist http User session attributes through the structure below?
Abstract Controller (just the main code):
public abstract class AbstractController<T> { @Inject private AbstractFacade<T> ejbFacade; private Class<T> itemClass; private T selected; private Collection<T> items; //GETTERS AND SETTERS OMMITED public AbstractController(Class<T> itemClass) { this.itemClass = itemClass; }
I am trying to use three cookies in a servlet to store the background and foreground color and text size but my code is not working for some reason. When I run the servlet I get an IndexOutOfBounds exception and in my code is says my cookies are not ever used, when they should be to store the variables?
I've 2 tables in my MySql DB,Employees and Assets & I want to pick 2 columns Employees and one column from Assets,then how would I display them into a JTable??
I am making an application in which I have to make the model (the services) available to the entire application so that all beans can access it and call its methods during the life of the application.
I am using the following technologies: view: JSF 2.x beans: Spring 4.x beans
The design problem I am having is the following:I came up with the idea of registering the model services as ServletContext attributes using my ServletContextListener, effectively making the services available to the entire application:
//imports public class MyContextListener implements ServletContextListener { //model services private UserService userService; private RepairService repairService; public void initCafe() { userService.removeAllUsers(); repairService.removeAllRepairs();
[code]....
Shouldn't I just use @Autowired userService and @Autowired repairservice everywhere I want to use these services application-wide?Or is this a problem because beans have a default scope of Request? I am confused.
I am wondering where the attributes I put into the Httpsession are stored.
For example, if I do the following HttpSession session = request.getSession(); session.setAttribute("usr", usr); session.setAttribute("pwd", pwd);
where does the ("pwd", pwd) pair store?
In my case, my web application needs to use the usr and pwd to login to another application, so I have to store them somewhere. So for security reason, if the pwd is kept in the browser side, I need to encrypt it first before I put it in the session. On the other hand if it is stored in the server memory then encryption seems not necessary
I found the following inheritance and encapsulation issue . Suppose you have a parent class with a non-static protected attribute.
package package1; public class Parent{ protected int a = 10; // this is the non-static protected attribute in question public static void main(String args[]){ // whatever logic }// end Parent class }// end main()
Now suppose you have a child class in another package and you have imported in the parent class.
package package2; import package1.Parent; public class Child extends Parent{ public static void main(String[] args){ Parent p = new Parent(); Child c = new Child();
System.out.println(p.a); //should print out 10 BUT DOES NOT System.out.println(c.a); //should print out 10 }// end main() }// end Child class
My observation is that p.a produces an error even though, to the best of my knowledge, it should not. I believe the statement "System.out.println(p.a);" should print out a 10.
Am I misunderstanding something about inheritance and encapsulation?
I am trying to make the variables that will be taken in from a type='text' box in HTML in NetBeans available to the other servlets as well as store and display the latest value passed into these boxes on the servlet page when the submit button is clicked or display null if the box has not yet received a value. However, I do not understand how to do this and do not understand as to why my current output is always null?
i) Is ServletContext().getAttribute("name of my textbox") really the way to pass the attributes to all servlets?
ii) Is ServletContext() passed in the service request?
iii) How to store the latest value passed into the submit box?
I have an Array of objects that contains strings. I am new to Java and have read books, the Java docs, and searched the Internet for my problem to no avail. How can I get my strings to print in a list so that the user can select an object to manipulate its attributes? I have a class called Instruments and created 10 guitar objects. Here is the code:
Instrument [] guitar = new Instrument[10]; for (int i = 0; i < 10; i++) { guitar[0] = new Instrument("Guitar 1"); guitar[1] = new Instrument("Guitar 2"); guitar[2] = new Instrument("Guitar 3"); guitar[3] = new Instrument("Guitar 4");
I am having an issue with using FileWriter to print some text to a text file. In the following code, I am supposed to be able to print the initial attributes and the user changed inputs into a file but all I am getting is the memory locations of the objects I created in one long line.
package project3final; import java.io.*; import java.util.*; public class Project3Final { static class Instrument { char [] stringNames = {'E', 'A', 'D', 'G', 'B', 'E'}; private final String instrumentName;