How can i make a servlet (class) temporarily unavailable, except for ADMIN

Hello All!
I am rather new to the programming field and have already completed a web-project in Java only with Servlets. (no jsp). I have a login procedure, means I have a user management for users and admins. If an admin is logged in, he/she should be able to deactivate the servlet with a mouse-click as long he activates it again with the same. if the servlet is deactivated, other users/admins trying to access the servlet should get a "servlet is currently unavailable" message. but the admin, who is logged in, still should be able to work with the servlet! how can i realise that?
in other words, by clicking that particular button, the servlet should be made "non-multi-thread" and other way round by activating it.
any ideas??? how can the standard "servlet currently unavailable" page be displayed? I have tomcat 4 on a linux machine! i'd be really grateful if someone oculd help me.
another question i have is, how to define a "pseudo" link address to the servlet. now, the servlet can only be accessed by typing like this: http://servername.xy.com:8080/ProjectName/servlet/ServletName (because I have activated the servlet mapping in the server.xml/web.xml with /servlet/*)
but I want a link like this: http://servername.xy.com:8080/shortname
How can I do this in an easy way?? I have treid to create a web.xml in der WEB-INF folder of the servlet with following content, but it is not working:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>
shortname
</servlet-name>
<servlet-class>
ClassName
</servlet-class>
</servlet>
</web-app>
Thanks a lot in advance for your kind help,
lisa

Ok,
You'll need to find a tutorial on servlet filters. Its not that hard a concept.
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/Servlets8.html#wp64572
Filters need to be configured in the web.xml.
Basically they are a buffer between a request and your servlet.
Any requests for the servlet, go through the filter first. It lets you do some processing before/after the servlet gets called. Its a good way of putting in some generic code that need to be run for many servlets - security checks are often implemented in this fashion.
This should give you an idea of the sort of thing you need. I haven't really written one before, so I copied this out of the tutorial and did some basic framework for it....
public final class TestFilter implements Filter {
   private FilterConfig filterConfig = null;
   public void init(FilterConfig filterConfig) throws ServletException {
      this.filterConfig = filterConfig;
   public void destroy() {
      this.filterConfig = null;
   public void doFilter(ServletRequest request,  ServletResponse response, FilterChain chain) throws IOException, ServletException {
        // if you want to get the session will need to cast request to an HttpServletRequest
        Session session = request.getSession();
        String requestURL = request.getRequestURL();
        // check if this URL is for a servlet that is disabled for this user
       // somehow you have to keep track of this ... maybe in the servletContext ?
    User user = (User) session.getAttribute("user")     
      boolean disabled = checkDisabled(requestURL, user);
      // if its not disabled, go ahead
      if (!disabled)
        chain.doFilter(request, response);
    else{
        // send the servlet off somewhere else - requestDispatcher maybe?
}

Similar Messages

  • How can i make buttons in an article to go for other articles in Folios Builders for Ipad?

    I am trying to make buttons in an index, for goingo to other articles, but they never worked here. When a i put Go to Destination, and choose de Indd file, it does not work.
    Can i make a scrollable frame a button either? When i tryed, it did not work, not even the button, and the scrollable frame.
    Please, need some help here.

    WHat is navto? is navegate to...?   How can i do this?
    thanks a lot for your attenttiosn.
    Em 29 jan 2014 às 06:26, Bob Levine <[email protected]> escreveu:
    Re: How can i make buttons in an article to go for other articles in Folios Builders for Ipad?
    created by Bob Levine in Digital Publishing Suite - View the full discussion
    Go to destination is unsupported in DPS. You should be using go to url with a navto: command.
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6064623#6064623
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6064623#6064623
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6064623#6064623. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Digital Publishing Suite at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.

  • How can I find the servlet class name from inside a ServletFilter?

    Ive implemented a servlet filter, but need to discover the class name of any servlet class that gets executed.
    Ive dug through the spec and cant seem to find any path to do this.
    Seems the methods needed to do this have been deprecated. (for security reasons?)
    Is there any way to write a ServletFilter to grab this info?
    If not, is there any other way to capture every servlet execution in the container, time its execution, and log the class name along with the execution time?
    (***WITHOUT*** requiring a classpath over ride of any container provider classes)
    Any help is much appreciated. Been banging my head against this for some time now :(

    request.getServletPath() returns the part of the URL which refers to the servlet. It isn't the classname of the servlet but it should be a reasonable surrogate. If you log that, then you could write some code which reads your web.xml and uses the servlet-mapping elements to convert it to servlet class names later.

  • HT1766 How can I make a NEW backup WITHOUT getting prompted for a (forgotten) password?

    Hello! 1st post here,
    How can I backup iPhone A to iTunes and then restore into iPhone B without getting prompted for a backup password that I do no know or remember ever setting?
    To clarify, I am not trying to read an encrypted backup. I would like to make a NEW backup but I do not want it to be encrypted as I do not know nor remember how a password was set in the 1st place. If I unclick the encryption checkbox, I am prompted to enter the password. Defeats the purpose of clicking on the box, no?
    Thanks,
    Henry

    Have you tried deleting the encrypted back up?

  • How Can I Make A Large Photo with Product Detail for My Thumbnails in Dreamweaver

    Hello All:
    New to Dreamweaver, so my code knowledge does not exist yet. Have Mercy!!!!
    Anyway , I am making a typical product page.
    I prefer that when people click the thumbnail product photo to not have to click into another brower.
    Nowadays you are able to click in what is commonly called a "Quick View" that pops up and gives you a full sized
    image along with product detail, and pricing.  That's all I want.
    How can I link this [the larger photo and product detai] to my thumbnails in Dreamweaver???? 
    I want the look that is on every website like Target, Macy, etc.
    Someone, please help me to  !!!!!!!
    These lil' faces are really cute.  They are helping me to smile after hours and days, weeks of frustration.   TWIN MADDOG!!!

    Hi,
    don't understand your problem, ore hope to understand it right. You could put the images on a DW file and link to another file with the larger image and where you have written all your informations.
    I made this here only for a new, larger image (without additional informations):
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Unbenanntes Dokument</title>
    </head>
    <body>
    <p><a href="pflanze1_l.jpg" target="_parent"><img src="pflanze1_s.jpg" alt="Thumbnail01" width="100" height="75" border="0" /></a></p>
    <p><a href="pflanze1_l.jpg" target="_parent">or this you use an Hyperlink to the larger image</a></p>
    </body>
    </html>
    s=small; l=large
    Hans-G.

  • How can I make an Apple ID as a developer for apps ?

    How can I create an app and then post it to the App Store ???

    Use iTunes Connect to publish an app
    Then you should archive your project, then publish your binary.

  • How can I make one cell search multiple other cells for a string of text and return whether or not the string appeared in the cells searched?

    https://www.icloud.com/iw/#numbers/BAI31boMQXsGKc8NH22BlqWRzbs8PdgWBs-F/2014-15_ Curriculum_Planning_w_CCSS_(Web_Shared)
    My document is above, if anyone wants to help this crazy teacher invent a better lesson planner.
    Here's my predicament.  The state in which I teach requires teachers to keep up with which of the Common Core State Standards (CCSS) their instruction is addressing and when the standards were addressed.  I got the bright idea to do this through a spreadsheet in Numbers because our school is getting iPads this year, so it'd be pretty sweet to be able to assemble all of my lesson plans in one massive spreadsheet.  On the "AP Lesson Plans" sheet, I've got a few weeks worth of lesson plans entered in.  I'm planning on going in and using the drop-down menu next to each lesson plan to add all the CCSS on a per-day basis.  This is simple enough, but here's where I run into a problem.
    I want the "AP Standards" sheet to concatenate, in cells D3 through G76, the dates on which a standard was covered.  What I need is some way for, say, Cell D3 to look at the table on the "AP Lesson Plans" sheet and concatenate the dates of every lesson which has the standard in column A (In this instance, RL.11-12.1).  At the end of the day, the functionality I need is that I can enter my lessons and CCSS on the "AP Lesson Plans" sheet and go to the other sheet and see a summary of which standards have been addressed, when, and how often.
    If that's as clear as mud, well, I teach literature, not technical writing, so my apologies.  I'm more at home with Jonathan Swift than spreadsheets.  I'll gladly help you help me if you'd let me know what you need to know.  Oh, and to illustrate my knowledge level (just enough to be dangerous), I've left you the formula of my best stab at making cell D3 behave as desired.  It's the gray box on the "AP Standards" sheet.  Yikes.

    Hi Arrdenet,
    Congratulations on the nested IFs. I haven't tested that formula, but it is impressive. It will be very difficult to debug if it doesn't work, and I think it would make Numbers very slow.
    Here is a different approach. After you enter all the CCSS, add another column with HLOOKUP.
    Edit:
    B2 (and Fill Down)
    A2 (and Fill Down)
    =IFERROR(HLOOKUP(A$1,C2:E2,1,0),"")
    HLOOKUP looks for the value in A1 in all the CCSS columns.
    IFERROR is to stop the error triangles appearing and returns "" (NULL) instead.
    Then sort by column A.
    Not a complete answer, but it might get you started.
    Regards,
    Ian.

  • How Can I make the toggle navigation OFF a default for an user

    HI, working with ISS6 Windows 2003 and Xir2 (SP3) I am trying to make one specific user (Or all users) to have hidden (grapped) by default the navigation panel in Infoview, but this setting seems to pick the default (Display=true) not from the user's session, but from someplace else.
    What can I do to avoid the Infoview to display the folder tree under the navigation panel?
    Thanks
    Reinaldo Nunez

    You might want to check this out.
    http://diamond.businessobjects.com/node/6042
    <a href="/blog/10">Rob&#39;s blog - http://diamond.businessobjects.com/robhorne</a>

  • How can I make cuable sound effects on seperate tracks for use in the theatre

    I need to make cueable music and sound effects for a play I am producing. I wonder if I can do this with FCE. The effects need to be on separate tracks on a CD so that the guy running the show can skip to the next track and push play. Help!

    Wouldn't iTunes be more appropriate for this?  There doesn't seem to be any video involved.

  • How can you make a psd gif  have transparent background for use in photoshop ?

    Hi Guys
    I'm trying to produce a 2d animation within premier pro cc using photoshop cc and
    i was just intrested if there is some way of changing a gif's  standard background to 
    a transparent background which i can then import  into premier pro cc to produce a 2d animation
    Thanks

    every time i export the image lots of tif files pop up on my desktop is there a more simpler way of producing a file which i can drag and drop into premier pro as an animation with a transparent background ?

  • How can I make a photo cd that is compatible for windows users?

    I need to make a photo cd from my iphoto library that will be compatible with Windows computers.  In my older iphoto program on my iBook G4 that was not a problem.  In iphoto '11, I get a message saying I need to follow some other instructions for cds for windows.  I'm having trouble with the alternative.  I must be missing something.  Is there a simple explanation?  Or will this always be a chore with the new program?
    Thanks for any help,
    Sheila

    Select the photos in iPhoto, export them to a desktop folder - see the user tip on exporting for details on the export options - and using the finder burn that folder to Disk
    LN

  • In imessage i cannot see messages that come in unless i have replied to the message. how can i make my iphone show me my inbox for sms?

    In immesage I cannot see messages that have come in to my phone unless i have replied to the message when it came in

    No, that's not a feature of the phone.
    You can submit feedback to Apple requesting such a feature here:
    http://www.apple.com/feedback

  • How can i make a suggestion on a good update for the iphone

    Hi I am Michael Hendrickson a third gen iphone holder.  I receintly thought of an idea regarding the "notes" app. Myself and everyone I know uses this app mainly for lists, I feel that it would be in our best intersts to be able to swipe with the finger and cross the item off (with a line) and/or completely erase the item from the list. I hope this helps future and current iphone users, please let me know if this helps.
    Thank you,
    Michale Jason Hendrickson
    iphone user

    http://www.apple.com/feedback/iphone.html

  • How can I make a folder in the TV for my home movies

    How can I make a folder in the TV shows for my home movies collection?  I have created a folder in the library in finder and put all the videos in there but they do not appear in itunes.
    pshultz

    It's best to never move iTunes media around in Finder. Add it to the Library through the iTunes interface by dragging them into the window. Once they've been added to the library, you can try using Get Info on the files in iTunes and change the tag info to make them group together. (A unique album name should do this.) If you want them to be included with TV Shows, you can try using Get Info to set the Kind to TV Show (found under the Options tab in Get Info), but I'm not sure if it will work. Otherwise, you could make a playlist and drag them into to access them all in one convenient spot.
    If you add the items as noted above and they still do not appear in your library, it's probably because they are not a compatible format.
    Message was edited by: Diane Wordsmith

  • How can I make server use single class loader for several applications

    I have several web/ejb applications. These applications use some common libraries and should share instances of classes from those libraries.
    But applications are being deployed independently thus packaging all them to EAR is not acceptable.
    I suppose the problem is that each application uses separate class loader.
    How can I make AS use single class loader for a set of applications?
    Different applications depend on different libraries so I need a way that will not share library for all applications on the domain but only for some exact applications.
    When I placed common jar to *%domain%/lib* - all works. But that jar is shared between all applications on the domain.
    When I tried to place common jar to *%domain%/lib/applibs* and specified --libraries* attribute on deploying I got exception
    java.lang.ClassCastException: a.FirstDao cannot be cast to a.FirstDaoHere http://download.oracle.com/docs/cd/E19879-01/820-4336/6nfqd2b1t/index.html I read:
    If multiple applications or modules refer to the same libraries, classes in those libraries are automatically shared.
    This can reduce the memory footprint and allow sharing of static information.Does it mean that classes should be able to be casted ?

    You didn't specify which version of the application server you are using, but the config is similar as long as you know what to look for. Basically, you need to change the classloader delegation. Here's how it is done in 8.2
    http://download.oracle.com/docs/cd/E19830-01/819-4721/beagb/index.html

Maybe you are looking for