Accessing Servlets in Browser

Hi all
I am new to servlets and till now everything went well but one thing! :)
I am trying to access a servlet I did through the browser. When I added the servlet class to the ROOT/WEB-INF/classes dir I could access the servlet by typing http://localhost:8080/servlet/HelloWorld such that HelloWorld is the name of the class. This all went ok and I accessed the servlet with success.
Now I wanted to put my servlet in another directory. I created a dir called my-servlets under the dir webapps of TomCat 5.
Inside I created a dir WEB-INF. In the web.xml file I specified the servlet HelloWorld and the mapping. If I try to access the servlet in the browser through the mapping it works fine.
But if I do http://localhost:8080/my-servlets/HelloWorld and HelloWorld is the name of the class I get an error: The requested resource is not available.
My question is: If I have my servlet in another dir than the ROOT I cannot access it through the class name? Or am I doing something wrong?
With best regards,

Try
http://localhost:8080/my-servlets/servlet/HelloServlet
The /servlet/ is a key to a special handler that loads servlets rather than a directory that holds servlet classes.
Also, make sure that you didn't stuff HelloServlet into a package. If you did, you'll either need a url-mapping in the web.xml file or a fully-qualified classname in the url.
For example, if HelloServlet is in 'mypackage', you'd use:
http://localhost:8080/my-servlets/servlet/mypackage.HelloServlet

Similar Messages

  • How to access Servlets in WLS examples

              I am trying to access Servlets stored in myserver/servletclasses/examples/servlets
              directory. .class files are here. When I tried to access a servlet in a browser,
              I am getting error. Can any one help me?
              

              In Weblogic 5.1, each example (souce code) in $WL_HOME/examples) comes with a very
              good and detail instruction. Read these instructions will definitely help you
              to understand Weblogic 5.1. Weblogic 6 is a little bit different, but most instructions
              are still useful.
              "magunta" <[email protected]> wrote:
              >
              >I am trying to access Servlets stored in myserver/servletclasses/examples/servlets
              >directory. .class files are here. When I tried to access a servlet in
              >a browser,
              >I am getting error. Can any one help me?
              

  • Accessing servlets using login and goto

    Hi,
    I'm having a problem in accessing servlets without visiting the DesktopServlet. There is no problem if the servlet does not require a parameter, but if I try to pass a parameter to the servlet, it does not pass the parameter -
    Without visiting the DesktopServlet when I try to visit an servlet X , it gives me a session exception.
    Thrown SessionException : Invalid service host name.
    I use the following code to login and go to the servlet :
    String redirectTarget = "login?&goto=" + req.getRequestURI() + "&hotelComponent=" + hotelComponent;
    resp.sendRedirect(redirectTarget);
    Inside the doGet of the servlet, I now try to read the hotelComponent parameter -
    String hotelComponent = req.getParameter("hotelComponent");
    But now I get a null. I can not get the hotelComponent parameter. Any suggestions will be very helpful
    Thanks in advance
    Partha

    Thanks for the suggestions ! The original problem of not being able to pass parameters like -
    "login?&goto=" + req.getRequestURI + "?param=" + value"
    has been solved by encoding the URL string sent to resp.sendRedirect.
    However the suggestion you have given regarding setting of cookies in the browser might have a bearing on my actual problem. I'm trying to do away with the redirection to the login servlet in the DesktopServlet.
    Here is what I'm trying to do to make our website searchengine friendly - using WGET scrape the DesktopServlet and set it as the index.html. When somebody tries to access the links which are ordinary servlets, it gives a session exception. I catch the session exception and in the catch block use "login?&goto" to do a response.sendRedirect. This does a login and gets me the session.
    All the servlets work fine except for one which is identical to the ones working except for the fact it is a post from a form on the DesktopServlet. Here I get a HTTP 400 Bad Request error. I've noticed that when I clear the cache and try I get a better response.
    Any suggestion on how to overcome this ( possibly by setting cookies ) would be greatly appreciated.
    Thanks in advance

  • I want to airplay from macbook pro to apple tv. What are the possibilities? Does it allow me to play movies or videos I access through the browser as well?

    I want to airplay from macbook pro to apple tv. What are the possibilities? Does it allow me to play movies or videos I access through the browser as well?

    Welcome to the Apple Community.
    Only content in your iTunes library can currently be sent via AirPlay from your mac.

  • Getting Servlet Exception while accessing servlets after deployment

    Hi,
    Iam getting a Servlet Exception while accessing servlets after deploying into weblogic 8.1
    Error 500--Internal Server Error
    javax.servlet.ServletException: [HTTP:101249][ServletContext(id=9599010,name=MyWeb,context-path=)]: Servlet class LoginServlet for servlet LoginServlet could not be loaded because the requested class was not found in the classpath F:\bea\weblogic81\samples\domains\examples\MyWeb\WEB-INF\classes;F:\bea\weblogic81\samples\domains\examples\.\examplesServer\.wlnotdelete\extract\examplesServer_MyWeb_MyWeb.
    java.lang.UnsupportedClassVersionError: LoginServlet (Unsupported major.minor version 49.0).
         at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:834)
         at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:535)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:373)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    My Folder Structureis like this,
    F:\bea\weblogic81\samples\domains\examples\MyWeb
    MyWeb is the projectName
    F:\bea\weblogic81\samples\domains\examples\MyWeb\WEB-INF
    Inside WEB-INF, i have web.xml and weblogic.xml, and classes directory with servlet classes.
    Any help will be appreciated.
    Thanx in advance.
    Regards
    Ram

    Hi,
    Thanks for the reply.
    Yes you are correct, i compiled using jdk1.5.
    but my servlet code will not compile in jdk1.4 version since i used advanced vaector classes in that.
    Is there any settings like script file that need to be changed so that i can point to my jdk1.5 compiler rather than the default one pointed by weblogic.
    Thanks in advance
    Ram

  • Inexplicable delays in browser-to-servlet-to-browser communication

    We are seeing some inexplicable "pauses" in the round-trip from
    browser-to-servlet-to-browser communication. The browser and Weblogic
    instance are on different machines, so correlating absolute times has
    been difficult. So at this point it's hard to tell whether the browser
    request is not being received immediately by the servlet, or the servlet
    response is not being received immediately by the browser... or perhaps
    it is, but maybe the response stream isn't "closing" properly, causing
    the browser to think there's still more to come.
    If the browser request is not being received immediately by the servlet,
    it could be because the execute thread count is so low that the request
    is being blocked until a thread is availble to service it. But our
    thread count is set to 30 and this is with just a single user hitting
    the servlet.
    If the servlet response is not being received immediately by the
    browser, or is not being closed properly, what could cause that?
    Occassionally, I have been able to account for some of the "delay"
    time. Our servlet does the usual stuff: writes out to the response
    writer and then closes the writer:
    PrintWriter writer = response.getWriter();
    writer.write( htmlString );
    writer.close();
    I have seen the writer.close() method taking a long time - over 5
    seconds on one occassion! What could it be doing?
    Could some type of TCP_NO_DELAY network setting account for all of
    this? Any and all help/experiences are appreciated.
    mg
    Mike Gorman, Director of Architecture
    YOUcentric, Inc.
    Charlotte, NC
    704-643-1000 x518
    http://www.youcentric.com

    If you are using 5.1 and you have ELF turned on (see docs).
    You can specify "time" as an ELF header and this gives you the time of
    processing and the write.
    mbg
    In article <[email protected]>, [email protected] says...
    Here are a few top of the head suggestions:
    1. You can log the time when the request is received by the servlet and
    when the output stream is closed. That should give you a fair idea of
    what percentage of delay happens on the servlet side.
    2. Try flush() to send stuff to the browser after every few lines of
    write(). It helps.
    3. IE does wait for the whole HTML to come in before it displays unlike
    Netscape which shows the streaming data. So switch browser and check.
    4. Make sure you are not using the SingleThread model even though that
    does not explain the delay encountered by a single user.
    If these do not help, you would need to give more insight into the code.
    - Anshum
    Mike Gorman wrote:
    We are seeing some inexplicable "pauses" in the round-trip from
    browser-to-servlet-to-browser communication. The browser and Weblogic
    instance are on different machines, so correlating absolute times has
    been difficult. So at this point it's hard to tell whether the browser
    request is not being received immediately by the servlet, or the servlet
    response is not being received immediately by the browser... or perhaps
    it is, but maybe the response stream isn't "closing" properly, causing
    the browser to think there's still more to come.
    If the browser request is not being received immediately by the servlet,
    it could be because the execute thread count is so low that the request
    is being blocked until a thread is availble to service it. But our
    thread count is set to 30 and this is with just a single user hitting
    the servlet.
    If the servlet response is not being received immediately by the
    browser, or is not being closed properly, what could cause that?
    Occassionally, I have been able to account for some of the "delay"
    time. Our servlet does the usual stuff: writes out to the response
    writer and then closes the writer:
    PrintWriter writer = response.getWriter();
    writer.write( htmlString );
    writer.close();
    I have seen the writer.close() method taking a long time - over 5
    seconds on one occassion! What could it be doing?
    ==================================================
    NewsGroup Rant
    ==================================================
    Rant 1.
    The less info you provide about your problem means
    the less we can help you. Try to look at the
    problem from an external perspective and provide
    all the data necessary to put your problem in
    perspective.

  • Display PDF document from Servlets to browser - how 2 change the title

    Hi, need help of changing the html title when Display PDF document from Servlets to browser. By default the browser's title shows the obsolute URL where the rdf comes from (i.e. http://www.google.com/sample.pdf), because servlet responds a binary data (PDF), there seems to be no other way to change the browser's title to fit my own choice.
    Appreciate your quick help,

    You can try and check with
    .setTitle("Welcome");

  • I am unable to access Elements Inspiration Browser in Elements 10 Editor

    Does anyone know why I can't login (using my Adobe Id) when trying to access Elements Inspiration Browser from the Editor?

    Photoshop.com and the IB are dead and gone, have been for well over a year. There is nothing to log in to anymore.

  • An unrecognized HTTP response was received when attempting to crawl this item. Verify whether the item can be accessed using your browser.

    I have 2 WFE behing F5 that handles ssl termination too. I have a site abc.xyz.com.
    At aam i have
    http://abc.xyz.com in default zone and https://abc.xyz.com in internal zone.
    AT sharepoint content source; I have both http and https of the above site version.
    DNS entry of abc.xyz.com is pointing at VIP in f5 which load balances this site at 2 different ips assigned to each web front end server.
    Now when i run search in this content source, searchable item populates but there is error for http request telling An unrecognized HTTP response was received when attempting to crawl this item. Verify whether the item can be accessed using your browser.
    Why is this happening?
    Is it because requests are coming to f5 as https but search is returning it as http? Will SSL termination removal from f5 solve this issue which i really don't want to do? Will pointing dns entry to two ips in wfe instead of f5 VIP will work?
    Adit

    Hi,
    I have seen a similar post from you, my understanding is that when you ran search in your content source, there was an error. You can take a look at the following thread:
    http://social.technet.microsoft.com/Forums/en-US/94e999e3-4128-4674-97dc-e46e71fe0f46/search-service-setup-behind-f5-an-unrecognized-http-response-was-received-when-attempting-to-crawl
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Accessing Servlet by jsp: forward

    I want to access Servelt by hyperlink in a jsp web site
    connection.jsp
    <%@ page contentType="text/html;charset=GB2312" %>
    <HTML>
    <BODY bgcolor=cyan><Font size=1>
    <A Href="/myjsp/Hello" >Accessing servlet<A>
    </BODY>
    </HTMLi put the bean in the dir(/myjsp/WEB-INF/classes/hello(package)/Hello)
    and modify the file web.xml like this:
    <servlet>
            <servlet-name>Hello</servlet-name>
            <servlet-class>hello.Hello</servlet-class>
        </servlet>
        <servlet-mapping>
           <servlet-name>Hello</servlet-name>
           <url-pattern>/Hello</url-pattern>
        </servlet-mapping>it works!
    but if i use <jsp:forward>
    <html>
         <body bgcolor="green">
         <jsp:forward page="/myjsp/Hello" />
         <body>
    </html>it causes an Exception The requested resource (/myjsp/myjsp/SimpleServlet) is not available.
    why? why the path have /myjsp/myjsp....?
    Thanks

    only one wrong u have done that is
    U have to give :
    <jsp:forward page="/Hello"></jsp:forward>
    but not
    <jsp:forward page="/myjsp/Hello"></jsp:forward>
    the reason is that when u run a jsp file , a servlet is generated for that
    jsp file. so calling a another servlet from that servlet(servlet of connection.jsp) can be done by just giving url -pattern. No need to give
    /myjsp/Hello .
    regards,
    reply after u get

  • Unable to run a servlet in browser

    hello everyone,
    i am working on url rewriting technique of Session management ....
    i am using deploytool provided by sun java system application server platform edition 8.2 ....after deploying my class files succesfully
    when i try to run the servlet in browser...
    eg....
    http://localhost:8080/contextroot/servlet/myServletname
    i get the following error
    HTTP Status 404 - /rewrite_cntx/servlet/RewriteServletURL
    type Status report
    message /rewrite_cntx/servlet/RewriteServletURL
    description The requested resource (/rewrite_cntx/servlet/RewriteServletURL) is not available.
    Sun-Java-System/Application-Server
    guys,i've checked it about a hundred times..i prperly attach the class files as required....still i'm unable to find out why this is happening..
    somebody please help me.

    I never used the deploytool, but it would be laughable if the tool doesn't allow you to map servlets to URLs. A quick look [at the J2EE 1.4 tutorial|http://java.sun.com/j2ee/1.4/docs/tutorial/doc/] suggests you can do it by first adding new components to the application (one for each servlet) then using aliases to map the servlet to a URL. I suggest reading the tutorial and following step by step. It will probably make more sense that way.
    If that doesn't work, stop using the deploytool and start packing your WAR file manually. You should:
    1) Know what directory structure a web application requires.
    2) Know how to generate a WAR file (note: a WAR is a JAR with a WEB-INF directory and a different extension)
    3) Know how to generate a web.xml document.
    If you don't know how to do that stuff, it is time to stop relying on the deploytool anyway and learn how to it works. A tool such as the deploytool (and IDEs) should be a convenience, it should not be a replacement for knowing the basics.

  • After getting a txt message from bell today saying I went over on my data usage , I can not access my web browsing at all... There is no restrictions on my account. But I still can't load safari

    After getting a txt message from bell today saying I went over on my data usage , I can not access my web browsing at all... There is no restrictions on my account. But I still can't load safari... I can still makes calls and send txt messages but I can't send iMessages

    Settings > General > Reset > Reset Network Settings.

  • I have a new printer which behaves OK except it will not print directly from a web site accessed via Firefox. We do not have this problem if accessed via another browser. Suggestions?

    New printer is Brother MFCJ615W. OS is XP. Computer is quite old Dell. Printer also refuses to print pictures from .jpg files - but the fact that I can print direct from web sites accessed via another browser suggests some of the problem is with Firefox. I asked this a few days ago and got an email reply giving me a link to click on - but this only produced an error message.

    I think I solved the wifi connection problem, just by switching off completely the router! sounds trivial, but in this case it worked!!!
    the funny behaviour of the trackpad/cursor still persists. any suggestion???
    thanks again

  • Xdb username and password while accessing servlets

    Hi all,
    I just installed application server 8.2. I wrote a simple login.html and a servlet program. The deployment went fine but when I access from browser and click sunbit in login page, it asks for a xdb username and password. I don't remember giving it during installation. What is this?
    Thanks

    Hint: "Search Forums" feature can be your friend :-)
    http://forum.sun.com/jive/thread.jspa?forumID=129&threadID=52586

  • HELP URGENT : accessing servlets thru localhost

    Hi
    I am trying to access a servlet on iplanet from another servlet through forms .
    when i specifically give the machine name and point the form to
    <form name=form1 action=https://avenger/servlet/LoopQualServlet method=GET>")
    where avenger is my local machine it works fine and gets redirected .
    But when i try to do the same thing using localhost its not working..
    I gave
    <form name=form1 action=https://localhost:8443/servlet/LoopQualServlet method=GET>");
    Can someone pls help me figure where i am going wrong.???
    Thx in advance ..
    prabhu

    hi
    thx for the help.....Yes, both servlets are on the same iplanet server.I just tried the samething u said before seeing your post ...It worked....
    But one more question though.... I am trying to access the first servlet from the browser by typing https://localhost:8443/servlet/LoopQualPage...This then gets redirected to another servlet thru forms i discussed earlier...It doesnt work .
    But when when i try to say specifically https://avenger/servlet/LoopQualPage it works fine....
    Any clue how i can access the first one the same way i was able access the second one thru forms without actually typing the machine name???????
    Thx in advance
    prabhu

Maybe you are looking for