What jar cover's java.servlet???

I've messed with servlets before but now am stuck. If I bring in servlet.jar or any jar's from javaEE into my compiler's class path it see's the javax.servlet package but not the java.servlet package. Which jar file do I need to see and compile the java.servlet package?

There is no standard java.servlet package, the only servlet package is the one that comes with J2EE, so what exactly is your problem? Also with the command:
jar tf your_jar.jar you can see the contents of every jar file.

Similar Messages

  • Confused what exactly Java Servlets are?

    Hi,
    I(JSP Biginner) have gone through some tutorials about JSP, Servlet and Java bean.
    I'm really confused by the term SERVLET.
    There are a lot of the definitions:
    1.) Is a Java Class that provides special Server Side Specification.
    2.) A servlet is a dynamically loaded module that services requests from a Web server.
    From above mentioned definition, my understanding is, SerVlet is like an engine which is provided server service. Is the SERVLET that I mentioned same as the JSP Servlet Engine which parse the JSP file, generate and compile the servlet source code and then send it to the browser?????
    3.)What about the SERVLET that created by developer and use in the JSP page? what are the differents between the servlet 1,2 and 3.
    Please advice!

    thanks so much...
    guess I have better understand of what java servlet is when I read the article from
    http://www.novocode.com/doc/servlet-essentials/
    from my understanding:
    1.) we said that SerVlet Provides Request and Response services is because the purpose of we creating our servlet is used to Read (Request) the data from Client and Send back (Response) the data to the Client. Of course all this can be done by code in the JSP page, but because of SerVlet technology, instead of we write the long code in the JSP page, we can modularise our code by creating servlet, why?? as servlets are web components, they can be reused easily. Moreover, java servlet is platform independent. After that at our JSP page, we just call the servlet we have created.
    2.)As we can see from all the example, a SerVlet sure has
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    Are all of them only available when we installed our Web Server (i.e tomcat)???
    3.)Can I say that we create servlets by Inherit all the routines and structure in those classes (q.2), as well as use their Built-In functions to create our servlets???
    4.) Can I say that we create servlet by create an instance of a BIG SERVLET which served as a base (Which has all the classes we needes for creating our own servlets)
    I don't know how much you can understand what I'm writting. Anyway, hope u can help.
    Thanks so much.

  • What is wrong with the following Java servlet code that downloads files?

    Hi,
    I need urgent help.
    This is the issue. I have a JSP code that calls a Java servlet class. This class is used to download files from the JSP page. The following is the piece of code that does the file download.
    String pathOfFile = gsPath + "/" + gsFileName.substring(gsFileName.indexOf("~")+1);
    File F = new File(pathOfFile);
    res.setContentType("application/stream");
    res.setHeader("Content-Disposition", "attachment; filename=" +gsFileName.trim());
    This code works just fine with IE. However, when this is used with Netscape, the class name gets added to the original file name extension. For example, if the class name is 'FileRetriever' and the file being downloaded is originally named 'a.doc', the file gets a name of 'a.doc.FileRetriever' after download using Netscape or Mozilla.
    One way to solve this is by adding the appropriate file type in the MIME settings in browser preference. However, this not a permanent solution.
    Can somebody let me know the correct code to fix this issue?
    Thanks for your time.

    We loose control of the file name once we pass the original file name to the input stream. When our code instructs Netscape to write the file on the local disk using an output stream, that is when Netscape/Mozilla adds this additional extension to the original file. So, essentially, we do not know about this additional extension.
    Any ideas on how to resolve this?
    Thanks.

  • Java servlet class access

    Can a servlet running on server A access a class defined on server B?
    More information:
    I am new at Java servlet programming and want to make sure that my web application is secure. I have set up a Java class that returns some user information (name, email address etc) and I have set up some jsp and servlet pages that access the class via an 'import my.class...' for servlets and a '@page import ="my.class..." 'for jsp. The jsp and servlet pages do session checking and authentication but the class does none of that - it's methods just return the requested data. I do not want to put any authentication in the class but I want to be certain that there is no way some other web server out on the internet could access this class in my web application. I do not think it is possible but my fear is that some hacker out there could somehow remotely do an @page import "my.class..." on my webserver and then gain access to my class methods? These web apps are running inside a Glassfish 3.0 app server.
    Thanks!

    user479480 wrote:
    That is very helpful info. I have been writing a lot of functional type code (updating, selecting and returning database data etc) inside Java servlets but when I get a new requirement I end up rewriting the same code in new servlet pages. So I have been thinking of putting all of that functional code in classes that I can re-use but was unsure of the security access and did not want to clutter the classes up with a bunch of session/authentication checking.
    Do you recommend any books on J2EE Web programming? Thanks again for your assistance.Code re-use isn't a problem that way, because you can put your common code into a library jar and use it in as many JVMs as you like. What you can't do is to access any Java objects running in one JVM from another one, whether or not they are on the same machine.

  • In what jar is: com.sun.activation.registries.MailCapFile located?

    I am attempting to implement JavaMail in an application in an OS400 environment. I simply want to send a text message (no attachements). My code works up to the point of: Transport.send(message); where I get a NoClassDefFound: com/sun/activation/registries/MailCapFile
    Here's the code:
    private void sendEmail(String recipient,String msg){
         String smtpSvr = "xxx.yyyyyyyyy.com";     
         String subject = "Log Transfer Errors";
         String from = "[email protected]";
         Properties p = System.getProperties();
         p.put("mail.smtp.host",smtpSvr);
         Session mailSession = Session.getDefaultInstance(p,null);
         Message message = new MimeMessage(mailSession);
         try {
         message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(recipient));
         message.setFrom(new InternetAddress(from));
         message.setSubject(subject);
         message.setContent(msg,"text/plain");
         Transport.send(message);
         } catch (AddressException e) {
              System.out.println(""+e);
         } catch (MessagingException e) {
              System.out.println(""+e);
         } catch (Exception e) {
              System.out.println(""+e);
    I have JavaMail working fine in a servlet running in WebSphere 5.0 on the same OS400 v5r2.
    Do I need to add another jar file to my CLASSPATH?? Don't know in what jar the:
    com.sun.activation.registries.MailCapFile class is in????

    From its name I would guess that it's in "activation.jar". In fact looking in that file on my AS/400, it IS in activation.jar. You must have missed the instructions that you would need that for JavaMail to work properly. You can get it here:
    http://java.sun.com/products/javabeans/glasgow/jaf.html

  • Package java.servlet does not exists

    I am getting this error:
    c:Program Files\Java\jdk1.6.0_10\bin>javac -Xlint HelloServlet.java
    HelloServlet.java:2:package java.servlet does not exists
    import java.servlet.;
    ^
    HelloServlet.java:4; cannot find symbol
    symbol: class GenericServlet
    public class HelloServlet extends GenericServlet
    ^
    5 errors
    i am using jdk1.6.0_10. i tried to locate the servlet.jar file in the \lib directory, but the jar file was not there. how can i download one and include it in \lib?
    import java.io.*;
    import java.servlet.*;
    public class HelloServlet extends GenericServlet {
    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter pw=response.getWriter();
    pw.println("<B>Hello!");
    pw.close();
    }

    jatilau wrote:
    forgive my ignorance.That's ok, we're all here to learn; but while (most) people on the forums are smart, they're (unfortunately) not all-knowing. They can't possibly know something about you or your environment unless you tell them.
    it is because i have no one to look up at for help with java, except for the book (The Complete Reference, Java 2, 3rd Edition, Naughton & Schildt) and, of course, some times this forum.There's the whole Internet available to you. Remember, Google is your friend.
    please, will anyone tell me how to find out what server type and version does JDK 1.6.0_10 provide? It doesn't. Java comes in three 'editions':
    Micro (JME, earlier J2ME which is meant for mobiles and other similar platforms)
    Standard (JSE, earlier J2SE which is what you're using, it's meant for core Java applications, like the sort you might use on your desktop.)
    Enterprise (JEE, earlier J2EE which is for server side code. This includes JSPs, Servlets, EJBs etc)
    i did not find any information about this in the book.Probably because it's a Java 'Standard' Edition (JSE or J2SE) book
    What you need, to learn about servlets, is a JEE book. I'd suggest Head First Servlets and JSP from O'Reilly. Otherwise, follow the link I gave earlier to find tutorials.
    To get started, you'll need a JDK, which you say you already have and a server. I'd suggest you get Tomcat. You will also find the servlet-api.jar after you setup Tomcat. This is an implementation of the JEE specification for servlets. This contains the javax.servlet.* packages you'll need to compile. Beyond this, the scope of what servlets are and how to deploy etc is rather large and best left to one of the afore-mentioned tutorials.

  • Compiling Java Servlet with Depricated Methods

    I have a problem of compiling Java servlets that contain depricated methods. If you compile against modern version of servlet.jar I see depricated methods error messages and if I use a very old servlet.jar it cannot find newer methods. What is is the best solution in this case?
    Thank you,
    Boris.

    The best thing to do would be compile your code with the -depreciated option to find which methods have been depreciated and the refactor your code to remove them.
    The next best thing is to ignore the messages (they are warnings not errors) and your code should still work

  • Help: No Parameters, HTML Output from Java Servlet

    I have a Java Servlet that reads parameters passed from an HTML form and displays them to another HTML page. I know the servlet is being invoked; however, I am not seeing any HTML output. Sending the output to a file reveals the parameters are coming in as NULL as well.
    I attempted a simple sample app with the same results. Here is what I am running:
    The HTML Form:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Collecting Three Parameters</TITLE>
    </HEAD>
    <BODY BGCOLOR="#FDF5E6">
    <H1 ALIGN="CENTER">Collecting Three Parameters</H1>
    <FORM ACTION="ThreeParams">
    First Parameter: <INPUT TYPE="TEXT" NAME="param1"><BR>
    Second Parameter: <INPUT TYPE="TEXT" NAME="param2"><BR>
    Third Parameter: <INPUT TYPE="TEXT" NAME="param3"><BR>
    <CENTER><INPUT TYPE="SUBMIT"></CENTER>
    </FORM>
    </BODY>
    </HTML>
    The Java Code:
    public class ThreeParams extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
         "Transitional//EN\">\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>\n" +
    "<UL>\n" +
    " <LI><B>param1</B>: "
    + request.getParameter("param1") + "\n" +
    " <LI><B>param2</B>: "
    + request.getParameter("param2") + "\n" +
    " <LI><B>param3</B>: "
    + request.getParameter("param3") + "\n" +
    "</UL>\n" +
    "</BODY></HTML>");
    What happens when I "submit" from the form is the same form reloads with the query string in the URL: "http://localhost:8080/ThreeParams/?param1=1&param2=2&param3=3"
    Any assistance with either (or both) would be thoroughly appreciated:
    a) why the parameters are not being passed correctly to the servlet
    b) why the HTML output page is not displayed
    Thanks in advance!
    - Steve

    I have found the answer to my problem listed in another thread.
    Thank you.

  • Deployment Issues, Different  Jars for Diff Java in one application.

    HI,
    I need to put classpath (Jars) for my WEB-INF/classes. Different Jars for Diff files in one application.
    The problem is , for one ofmy application, the lib files are x.jar and y.jar , x is older than y but have same
    lib files. in x and y, there is one class , r.java , which have a method method1(). whey they are doing modifications in y.jar , the r.java has changed to new vertion, the method method1() they re-written the body.
    My application have 5 java files, in which 2 files uses r.java imported from the x.jar earlier.
    Now we need to use y.jar because , the y.jar have more files added with good futures. But the earlier 2 files are giving exception if i use y.jar.
    I need solution for this. how can i put classpath for the 2 files to use the x.jar and other files to use y.jar in the same application.
    I am using a Tomcat 4 server. only Servlets, JSPs I am using.
    Thank you,
    Kiran

    I may be missing something here, is y.jar a newer version of x.jar? And if it is do you need x.jar at all? Are there classes in x.jar that do not exist in y.jar? Can you modify your application to provide the same functionality and only use y.jar?

  • Inputting an excel file to the java servlet program

    Hi,
    How can I input an excel file into the java servlet program? I am using POI HSSF programming to read the content of that excel file.I have created a form that will accept the path from the user and in the servlet program, I have called a post method to retrieve the path of the file. I am getting the path of the file as a string.Then I have to access the file to read the data. But it is not working. What should I do?.Please help me.
    I have created an html file to create a form that will ask the path of the file to be loaded into the servlet program.Please give me a solution,thanks in advance. The servlet program that receives the file is shown below. It just only take the name of the file and prints if that is ok.
    <html>
    <body bgcolor="green">
    <center>
    <form method="post"  action="http://localhost:8080/examples/servlet/Ron1">
    <table>
    <tr>
    <td><B>ENTER THE PATH OF THE FILE</td>
    <td><input type=file name="path"></td>
    </tr>
    </table>
    <input type=submit value= "submit" >
    </form>
    </body>
    </html>
    import java.io.*;
    import javax.servlet.*;
    import java.lang.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    import com.oreilly.servlet.MultipartRequest;
    import org.apache.poi.hssf.usermodel.*;
    public class Ron1 extends HttpServlet
       public void doPost(HttpServletRequest request, HttpServletResponse response)   throws IOException, ServletException
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String u = request.getParameter("FileToUpload");
            out.println("The Path is "+u);
            System.out.println("The path is "+u);
            MultipartRequest multi = new MultipartRequest(request,u,10 * 1024 * 1024);
            System.out.println("path is "+u);
            Enumeration files = multi.getFileNames();
            File fUploadedFile = null;
            String sFileName = "";
            out.println("path is "+u);
            while(files.hasMoreElements())
                            String name = (String)files.nextElement();
                            out.println("file is "+name);
                            sFileName = multi.getFilesystemName(name);
                            String type = multi.getContentType(name);
                            fUploadedFile = multi.getFile(name);
                    FileInputStream fis= new FileInputStream(fUploadedFile);
                   HSSFWorkbook wb=new HSSFWorkbook(fis);
                    System.out.println("The path is "+u);
                    out.println("File has identified successfully\n");
                    out.close();
       }

    Hi,
    Can you try to use classes from java.net package (URL, URLConnection) to pass the contents of excel file to servlet?
    HTH
    Vishal

  • When Streaming a PDF from a java servlet I get a grey screen on the Adobe Reader X plugin.

    I work on a webapp where we serve pdfs to clients by streaming via java servlets. Once we began to use Reader X we noticed that in IE the pdf will load Reader X with a grey screen. Chrome and firefox both work perfectly fine. If we use Adobe 9 it also works fine. We have no control over what our users use so any client side fix is not useful.
    We serve these pdfs to our user by opening a popup window to a url that streams the pdf directly to the response. We have noticed that if we have one popup window that has hit the grey screen - each new pdf in a popup works correctly - as long as the original grey screen is up, once all popups are closed the problem happends again. Refreshing the window with the grey screen will also show the pdf correctly.
    The problem is very similar to what is described here:
          http://forums.adobe.com/message/3335266
    However, we are not setting any caching headers - I have full control over what we can send and I have tried the suggestions - nothing works. Any ideas how to resolve this?

    You are prevented from Airplay mirroring certain things like DVD content as the material is usually protected so you get a checkerboard type display.  I think there is a theoretical risk that the Airplay stream could be intercepted and the protected video copied, albeitin lower quality.
    Apple may be being cautious or are required to do so with the DVD player app by movie studios/licensing authorities.  It makes no sense to the average consumer who is just trying to send their purchased DVD to the TV via the computer and AppleTV.
    Playback in something like VLC should work - not tried it myself but others have commented it doesn't have the restriction.

  • Java servlets - JDBC

    hi,
    I have a problem... i would like to fetch some strings from the database using JDBC and create a tree structure using java servlets to be displayed on a browser using html.
    Currently i have tried using a hashtable as well as defaultmutabletreenode, both of which grew complicated and did not give the desired results.
    Pls help...

    I tried using both a DefaultMutableTreeNode
    containing all the other nodes as child nodes and a
    hashtable with a series of internal hashtables -- and
    passed it to the servlet displaying the html
    l content.
    Is there a better/simpler data structure to use in
    this case other than a Hashtable and a
    DefaultMutableTreeNode?How should we know? You're asking what is better to solve your problem, without saying what your problem is. (Hint: "I can't do this" or "It doesn't work" are not useful problem descriptions.)
    If I were doing this, and if I had to build a tree structure in memory before producing HTML from it, I would use DefaultMutableTreeNode. But then I don't know anything about your problem.

  • What jar for com.sap.aii.mapping is

    Dear
    i am testing with blow blog.
    /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
    in this blog, java program use the following;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    what .jar file name is?
    i could not find com.sap.aii.mapping on eclipse.
    thanks
    Denis

    Denis,
    You need the <b>aii_map_api.jar</b> file for this.
    You will get this in the following location on your XI server,
    <b>j2ee\cluster\server0\apps\sap.com\com.sap.xi.services</b>
    Upload the Jar, in your Project Build Path.
    Regards,
    Bhavesh

  • Problem Installing Java Servlets Package

    I downloaded a sample servlet program which imports classes from the Java Servlets Package. I have the JDK 1.2 which does not come with the servlet classes (javax.servlet and javax.servlet.http). So I then downloaded them from java.sun.com. They come as a set of class files in .zip format. I thought packages were supposed to be in .jar format? At any rate, my compiler still fails to see these classes even after I have extracted these files into the same directory as the original .zip file and added this directory to my classpath. Am I going about this the wrong way? Any ideas on how I can make my compiler see these classes? --Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I down loaded j2sdk 1.4 . and also down loade servlet package. I installed in bin directory.
    i took the sample program and compiled. there is error message " java servlet package not found.
    please help. email me at [email protected]
    Thanks
    sri

  • Unicode, UTF-8 and java servlet woes

    Hi,
    I'm writing a content management system for a website about russian music.
    One problem I'm having is trying to get a java servlet to talk Unicode to the Content mangament client.
    The client makes a request for a band, the server then sends the XML to the client.
    The XML reading works fine and the client displays the unicode fine from an XML file read locally (so the XMLReader class works fine).
    The servlet unmarshals the request perfectly (its just a filename).
    I then find the correct class, and pass it through the XML writer. that returns the XML as string, that I simply put into the output stream.
    out.write(XMLWrite(selectedBand));I have set correct header property
    response.setContentType("text/xml; charset=UTF-8");And to read it I
             //Make our URL
             URL url = new URL(pageURL);
             HttpURLConnection conn = (HttpURLConnection)url.openConnection();
             conn.setRequestMethod("POST");
             conn.setDoOutput(true); // want to send
             conn.setRequestProperty( "Content-type", "application/x-www-form-urlencoded" );
             conn.setRequestProperty( "Content-length", Integer.toString(request.length()));
             conn.setRequestProperty("Content-Language", "en-US"); 
             //Add our paramaters
             OutputStream ost = conn.getOutputStream();
             PrintWriter pw = new PrintWriter(ost);
             pw.print("myRequest=" + URLEncoder.encode(request, "UTF-8")); // here we "send" our body!
             pw.flush();
             pw.close();
             //Get the input stream
             InputStream ois = conn.getInputStream();
                InputStreamReader read = new InputStreamReader(ois);
             //Read
             int i;
             String s="";
             Log.Debug("XMLServerConnection", "Responce follows:");
             while((i = read.read()) != -1 ){
              System.out.print((char)i);
              s += (char)i;
             return s;now when I print
    read.getEncoding()It claims:
    ISO8859_1Somethings wrong there, so if I force it to accept UTF-8:
    InputStreamReader read = new InputStreamReader(ois,"UTF-8");It now claims its
    UTF8However all of the data has lost its unicode, any unicode character is replaced with a question mark character! This happens even when I don't force the input stream to be UTF-8
    More so if I view the page in my browser, it does the same thing.
    I've had a look around and I can't see a solution to this. Have I set something up wrong?
    I've set, "-encoding utf8" as a compiler flag, but I don't think this would affect it.

    I don't know what your problem is but I do have a couple of comments -
    1) In conn.setRequestProperty( "Content-length", Integer.toString(request.length())); the length of your content is not request.length(). It is the length of th URL encoded data.
    2) Why do you need to send URL encoded data? Why not just send the bytes.
    3) If you send bytes then you can write straight to the OutputStream and you won't need to convert to characters to write to PrintWriter.
    4) Since you are reading from the connection you need to setDoInput() to true.
    5) You need to get the character encoding from the response so that you can specify the encoding in           InputStreamReader read = new InputStreamReader(ois, characterEncoding);
    6) Reading a single char at a time from an InputStream is very inefficient.

Maybe you are looking for

  • Need advice on a system setup / Final Cut Express or pro

    Hi all, I am about to take on a pretty big project. I will be working on a full length documentary, approximately 90 minutes running time. We currently have a 2 Ghz Intel Core 2 Duo iMac with 4GB of memory (667 Mhz DDR2 SDRAM) which we will be using

  • Calling custom BAPI from VB/VBA

    Hello, all, I have written a custom business object and its associated function module.  I can single-test the business object inside native SAP, and it works successfully.  I can also establish a handle to the business object from VBA (using the .Ge

  • Benefits: Employee Eligibility: Hire Date Override

    Hi, I have defined employee eligibility to use Hire Date Override to read from IT0041. However, when I run transaction HRBEN0001 for enrolment (i use this as default plan), I do not see the plans being offered if the selection date is before the Hire

  • Settlement Rule in Networks

    Hi Friends, I'm trying to create settlement rules for networks in CJ20N and facing issues. I have projects with WBS elements, networks, and activitieis (standard projects). System is allowing to maintain dettlement rules for WBS elements, but not for

  • LOV Query problem

    I have a very huge and a lenghty LOV Query . I am using 6i builder and when i save the module and try to reopen it , Only 3/4th of the LOV query is available and the remaining disappears . I can compile this in 6i by copying the query again but it cr