Home > Default > Abstract Classes and JSP

Abstract Classes and JSP

November 30Hits:0
Advertisement
Hi
I'm working on a tool wich can be used by different type of users. For example Employee, Administrator and Manager.
So I thought I could create an abstract class User with subclasses employee, administrator and manager
So depending on who logs on you could initiate the user:
user = new Employee()
However I'm not cuite sure how this works in JSP
Is there a way to do this in the jsp:useBean tag or somewhere else?
thx Babette

Answers

You might want to check out the Delegation Pattern. Its for exactly this case.
What happens if a Manager is also an Administrator? Do you give him two seperate logins to the system?
Most likely you just want a user object, and assign the users "roles"
One thing about the useBean tag it can take both a type and a class attribute:
http://java.sun.com/products/jsp/syntax/1.2/syntaxref1217.html#8865
Class is the actual class of the object to instantiate
Type is the type of object to declare it as - ie either a superclass or interface
<jsp:useBaen name="user" class="com.Employee" type="com.User"/>
Would generate code equivalent to
User user = new Employee().
Cheers,
evnafets

Read other 5 answers

Tags:

Copyright (C) 2017 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 12 q. 0.153 s.