Questions about Java Servlets and JSP

Hi,
I'm a confident Java Programmer (and really enjoy using this language) but am very new to Java servlets and Java Server Pages.
I have previously worked with Perl on my web projects (simple 'league' style voting pages). I read in my 'Core Java' book that I should no longer use perl or even cgi.
I need to know more about Java servlets and Java Server Pages so I can make the switch to a 'real' programming language.
I have a few questions:
How should I start to learn JS and JSP?
How applicable will the java knowlegdge I have already be?
Are JSP common on the world wide web?
What tools do I need to start? (I currently develop in JBuilder and have Java 1.4.1 Standard Edition)
Is it likey my web host (and others) will support JSP?
Thank-you very much for helping a novice get started,
Regards,
Paul

Hi, Steve ...has to be frustrating! But do not despair.
Let's suppose the servlet it's named MyServlet on package org.servlets
WEB-INF should look:
WEB-INF
classes
org
servlets
MyServlet.class
web.xml
web.xml file should have this two declarations:
<web-app>
  <servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>org.servlets.MyServlet</servlet-class>
  </servlet>
  <!-- other servlets -->
  <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
  </servlet-mapping>
  <!-- other servlets mappings -->
</web-app>Now, once the container starts (Tomcat?), you should be able to see that servlet in:
http://localhost:8080/[my-context/]MyServletAnd what my-context is? The web application context. This string should be empty if your're deploying to the root context, otherwise should the context name. In Tomcat, deploying to root context defaults to using webapps/ROOT.
Sorry for my English, but I felt the need to answer your request. I hope it helps despite my writing.

Similar Messages

  • Serving Java Servlets and JSP

    I have a small hosting company and was wondering what is required to be installed on a Win2k Server to host Java Servlets and JSP pages for a client of mine?

    Ah, so you just want to add a servlet engine to IIS5?
    Tomcat can be used as a plugin for IIS. Check out the Tomcat FAQs - somewhere in there you should find one relating to using Tomcat as an IIS plugin. They're far more comprehensive than I could ever hope to be on the matter!

  • Some questions about Java servlets

    I am having some problems with my Java servlets. Here they are below.
    #1 I have a login jsp page. When user logs in, the MySQL database is queried. If a match, redirect to appropriate page. The problem is I can't seem to remain in the login page if there is no match, I get a blank screen. If there is no match, how can I redirect it back to the login screen? For example, my login screen is login.jsp. Here is my code below.
    while(rs.next())
    if(rs != null)
    String name = rs.getString("USERNAME");
    Cookie getUser = new Cookie("User", name);
    response.addCookie(getUser);
    String sql2 = "INSERT INTO answers (USERNAME) VALUES( '" + name +"')";
    ResultSet rs2 = stmt.executeQuery(sql2);
    response.sendRedirect("profile410.jsp");
    out.println("<p>inside if structure");
    #2 After I go to the first screen after login, I am filling out a questionaire, and everytime I click on a submit button a different servlet comes into play, called InsertRecords.java. Everytime I go from one jsp to another, information gets stored into a database, InsertRecords.java is controlling this. I use the below code.
    String delete = request.getParameter("delete");
    String question = request.getParameter("question");
    String value = request.getParameter("R");
    if (delete.equals("no") && !value.equals(""))
    String sql = "INSERT INTO answers (" + question + ") VALUES (" + value + ")";
    int numRows = stmt.executeUpdate(sql);
    out.println("Record has been inserted");
    String nextPage = request.getParameter("nextPage");
    Cookie[] cookies = request.getCookies();
    if (cookies != null)
    for (int i = 0; i < cookies.length; i++)
    String name = cookies.getName();
    String valuecook = cookies.getValue();
    Cookie getUser = new Cookie(name, valuecook);
    response.addCookie(getUser);
    response.sendRedirect(nextPage);
    the table is answer and the fields are ID, username, and q1, q2 q3, up to q11. the idea is upon login, the username gets stored into the answer table, the field username. I want the values stored in the same row everytime user jumps from one page to another based on his username. Goes to first jsp, q1 gets inserted, next jsp, q2 gets inserted, etc. But they all get inserted diagonally on different rows, not the same one, that is the problem. How can I fix this?
    #2 Based on the above code, say there is 11 jsp pages, remember, this is an online questionaire. When user logs in, he starts at the first jsp page, or question. When for example when the browser gets cut off at question6, when he logs back in, I want him to start at question4, if cut of at question 11, start again upon login at question 8. The reason, so he won't have to start from the beginning. Each question is on seperate jsp's. The way I see this happening is creating a session upon login and keeping that session. And grab 4th question when he logs back in, but I am not sure about how to go about it.
    Can someone help me please?

    Q1:
    Use the update command and not insert.
    Q2:
    Won't work. The user may log back in after the session has expired or from a different location. On log in look for a record for that user and what questions have been answered so far.

  • Question about Java,XSLT and XML

    I am new to Java and XML. I'm not quite clear the relationship between Java,XSLT and XML.
    To exercise, I am going to write a Java program that makes embedded calls to an XSLT processor(XALAN), to produce results for several constrained transformations from a given XML document(x.xml) such as:
    1.Transform the x.xml (which satisfies d1.dtd) in such a way that it now conforms to the DTD d2.dtd. Output the resulting xx.xml document.
    2.query some information from the x.xml and then form an Html output.
    3.summary some information, do some statistics from the x.xml and then form an Html output.
    I don't konw which java classes and XSLT functions might be used.(Actually I don't know how/where to start).
    Can anyone give me some clue ?
    thanks a lot!

    You must provide XSLT stylesheeds to specify transformations (1), (2),
    and (3); let's call those stylesheets task1.xsl and so on.
    The following code will transform x.xml into xx.xml according to task1.xsl. It gives you an idea which packages and classes to use, but it doesn't teach you proper Java programming technics :)
    import java.io.File;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    public class Test
        public static void main(String[] args) throws Exception
            TransformerFactory factory = TransformerFactory.newInstance();
            Source config = new StreamSource(new File("task1.xsl"));
            Transformer transformer = factory.newTransformer(config);
            Source source = new StreamSource(new File("x.xml"));
            Result result = new StreamResult(new File("xx.xml"));
            transformer.transform(source, result);
    }To read about XSLT, see:
    http://www.w3.org/TR/xslt
    there is a tutorial on using XSLT with Java:
    http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/xslt/index.html.

  • Question About Java Threads and Blocking

    I'm helping someone rehost a tool from the PC to the Sun. We're using the Netbeans IDE and the Java programming language. I took a Java course several years ago, but need some help with something now. We're developing a front-end GUI using Swing to allow users to select different options to perform their tasks. I have a general question that will apply to all cases where we run an external process from the GUI. We have a "CommandProcessor" class that will call an external process using the "ProcessBuilder" class. I'm including the snippet of code below where this happens. We pass in a string which is the command we want to run. We also instantiate a class called "StreamGobbler" my coworker got off the Internet for redirecting I/O to a message window. I'm also including the "StreamGobbler" class below for reference. Here's the "CommandProcessor" class:
    // Test ProcessBuilder
    public class CommandProcessor {
    public static void Run(String[] cmd) throws Exception {
    System.out.println("inside CommandProcessor.Run function...");
    Process p = new ProcessBuilder(cmd).start();
    StreamGobbler s1 = new StreamGobbler("stdin", p.getInputStream());
    StreamGobbler s2 = new StreamGobbler("stderr", p.getErrorStream());
    s1.start();
    s2.start();
    //p.waitFor();
    System.out.println("Process Returned");
    Here's the "StreamGobbler" class:
    import java.lang.*;
    import java.io.*;
    // Attempt to make the output of the process go to the message window
    // as it is produced rather that waiting for the process to finish
    public class StreamGobbler implements Runnable {
    String name;
    InputStream is;
    Thread thread;
    public StreamGobbler (String name, InputStream is){
    this.name = name;
    this.is = is;
    public void start(){
    thread = new Thread (this);
    thread.start();
    public void run(){
    try{
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    while (true){
    String s = br.readLine();
    if (s == null) break;
    System.out.println(s);
    //messageWindow.writeToMessageArea("[" + name + "]" + s);
    is.close();
    catch(Exception ex){
    System.out.println("Problem reading stream" + name + "...:" + ex);
    ex.printStackTrace();
    The "CommandProcessor" class calls two (2) instances of the "StreamGobbler" class, one for "stdin" and one for "stderr". My coworker discovered these are the 2 I/O descriptors that are needed for the external command we're running in this case. We're actually called the Concurrent Versions System (cvs) command from the GUI. Here's what we need it to do:
    We want to display the output real-time as the external process is executing, but we want to block any actions being performed on the GUI itself until the process finishes. In other words, we want to show the user any generated output from the process, but don't want to alllow them to perform any other actions on the GUI until this process has finished. If we use the "waitFor()" function associated with a process, it blocks all external process output until the process has completed and then spews all the output to the screen all at once. That's NOT what we want. Also, if we don't use the "waitFor()" function, the code just continues on as it should, but we don't know how to block any actions on the GUI until this process has finished. My coworker tried the following code, but it also blocked any output until the process had finished:
    while (s1.thread.isAlive() || s2.thread.isAlive())
    // We really don't do anything here
    I'm pretty sure we have to use threads for the output, but how do we instantly show all output and block any GUI actions?
    Thank you in advance for your help!

    You're talking about a GUI, but there's nothing in that code which is putting events into the GUI update thread. You also say that nothing happens to the GUI until the CommandProcessor.Run() method returns if you wait for the process.
    This implies that you're calling CommandProcessor.Run() in an ActionListener. This will block the GUI thread until it completes.
    I was going to explain what to do, but a quick Google informed me that there's a new class which is designed to help in these situations SwingWorker (or as a [separate library|https://swingworker.dev.java.net/] if you're not up-to-date yet).

  • Question about Java RMI and Eclipse

    I would like to create an application with which I can easily connect to a JAVA program, installed on a web server, through JAVA RMI. I have already created a ClientRMI.java and a ServerRMI.java and compiled them. The stubs also have been created properly.
    When I run the application outside the Eclipse editor, everything works just fine! However, when I want to integrate the files into a bigger project in Eclipse... and starts running it, he tells me he can't find the stub class or something like that. I need to place this one in the classpath but I don't know how to do that in Eclipse? Could anyone help me with this problem?
    Thanks!
    This is the fault message I get:
    no security manager: RMI class loader disabled)
    D-me

    Do you have an idea of what the answer to our
    question could be?I don't have much idea about the question myself. I was groping in the dark. :-)
    Anyway, the project classpath settings and the external jars (or dependent projects) are a few things which could be experimented with. I'm afraid I couldn't be much help without having a look at what you are trying to do. :-(
    Regards,
    x

  • SSL usage in JAVA servlet and JSP based web page

    I have several question to adjust security setting of my web page.
    First of all, When do we need SSL in web pages, are you advise to use this technique in medium level security needed web page which means no commercial data just information based..And Second question is if I need , How do I use SSL (secure socket layer) in my web page or what do I need to implement it in my JSP pages?
    My IDE is Websphere 5.0 and server is tomcat 4.1 and database server MS sql server 2000.
    Please don't answer my question with just giving URL's, try to explain me something detailed and supported with URL's and examples. I am just a beginner in security topics (specially SSL).
    If you help me, I am really appreciated.
    Thanks in advance.
    Ergin

    I have several question to adjust security setting of my web page.
    First of all, When do we need SSL in web pages, are you advise to use this technique in medium level security needed web page which means no commercial data just information based..And Second question is if I need , How do I use SSL (secure socket layer) in my web page or what do I need to implement it in my JSP pages?
    My IDE is Websphere 5.0 and server is tomcat 4.1 and database server MS sql server 2000.
    Please don't answer my question with just giving URL's, try to explain me something detailed and supported with URL's and examples. I am just a beginner in security topics (specially SSL).
    If you help me, I am really appreciated.
    Thanks in advance.
    Ergin

  • Need some project titles that can be done in java servlets and jsp or ejb

    I am final year cs engg student. I have completed course in java,j2ee. I have done the library management project in servlet. I need some project titles for my final year project. My interests includes, networking, desktop applications.

    Saish wrote:
    I'm not sure how to help other than to advise you will probably have the best success with something that interests you personally. You mention desktop applications and networking. Perhaps start with something Swing (or JavaFX) and perhaps use that to monitor a network, detect intrusions, dynamically load balance, etc. Really, it's whatever will stimulate you through a long project. If you have an idea in mind, but are having difficulties with how to come up with a spiffy title, then post more detail, and we can try and help.
    - SaishThanks Saish for your nice response.
    Whether It is possible to implement the cloud computing ? Is it possible ?

  • Question about java objects and handles?

    Let me see if I can explain what I have. Inside my originating Java code, I create an object, let's call it object A, from a class I that I DON'T have the source for. It's not my class. Object A in turn creates an object, let's call it Object B, from a class I don't have the source for. Then Object A creates another object, let's call it Object C, that I DO have the source for, and passes it the reference to Object B that it created. My question is this: In my originating Java code, how do I get a reference to Object B? Or, how can I get the reference to Object C, which would allow me to get the reference to Object B?
    Hope everyone understands that?

    Thanks for the reply. Perhaps I should have mentioned that Object A does not have a method to return a referenece to Objects B and C. That's my problem. Was just wondering if there is some other way to obtain those refereneces. The reason I mentioned that I don't have the source code for Object A is because if I did, I could obviously write a method that would return me the references.
    I'm not new to Java, nor am I an expert either. I'm pretty well up-to-speed on object oriented design though.
    I'll provide more specifics on my problem just in case there is a solution to my problem. My code (class) is attempting to establish a connection with a mainframe computer through a web server portal using terminal emulation software provided by a 3rd party vendor. They provide an SDK that contains all the java classes necessary to establsih the connection. To establish the connection, you are required to build a java Properties object that contains all the parameters for the connection (host id, etc.) and pass that properties object to the constructor for the "Object A" class. That object actually establishes the session object using the parameters object you pass it. The session gets displayed in a standalone Applet ("Object A" class extends Applet). You can click on the applet, sign in to the system, and do whatever just fine using your keyboard. However, I wish to send commands to the session from my originating java code. The session object has a method to send commands to the session, but to do that, I need a handle to the session object that was created. I don't have that, and it appears they don't provide a method to get that. Looks like the vendor's intent was just for the user to interface with the session/Applet via the keyboard.

  • Basic question about Java, UNIX and OAS

    Hi,
    Can I create an appication that contains GUI components like testbox and textfields etc...and then load/import it into OAS?
    Can I again, create such an GUI application and then load it UNIX platform and run it?
    The reason I asked because I did create an application which has a frame, a panel and couples of buttons, text fields then ftp it to Unix Solaris, when I ran it with jre command, I got the following message:
    java.lang.NoClassDefFoundError: Javax/Swing/UIManager at cms.CMSApp.main(compiled code) Exception in thread main
    Please anyone help me to clarify this, I don;t if we can do such things but I did not do it the right way? or we cannot do it at all. Thanks for your help
    Minh

    I'm not sure I understand where OAS fits in here.. Is this an applet?
    In any case, it sounds like the JDK version you are using is 1.1.x, and swingall.jar is not in the classpath.
    If it's an applet, then you need to edit the HTML file and add in swingall.jar.
    If it's an application, you need to edit the CLASSPATH environment variable and append the full path to swingall.jar
    (note: in Java2 (JDK 1.2, 1.3) swingall.jar is no longer seperate, it is part of the runtime classes of java, so you don't have to add anything to the classpath)
    Take Care,
    Rob
    null

  • About java beans and jsps

    hi,
    can anybody tell me is it good use only jsp for presentation and business logic.
    in terms of perfomence wise is it good practice.
    regards,
    sam

    I think you had better to write in a beans.otherwise,the work of maintenance will be difficult.

  • Question about java reflection and "int" type

    hi, using reflections I should invoke a Method (meth3) that have as parameter an INT type (not integer). I've tryed with this code:
                        int num = 3;
                        Class[] vettClax = {int.class};
                        Object[] vettParam = {num};
                        Method meth3 = temp.getMethod("meth3", vettClax);
                        meth.invoke(o, vettParam);My problem is that the int value is catched as an Integer value and reflection doesn't found a method that accept an INTEGER as parameter, who can help me?

    Works fine when I try it.
    public class t
        public static void main(String args[])
         throws Exception
         Class temp = t.class;
         t o = new t();
         int num = 3;
         Class[] vettClax = {int.class};
         Object[] vettParam = {num};
         Method meth = temp.getMethod("meth3", vettClax);
         meth.invoke(o, vettParam);
        public void meth3(int n)
         System.out.println("hello " + n);
    }Is your meth3() public?

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • InterMedia Java Classes for Servlets and JSPs and Netscape

    I am using the interMedia Java Classes for Servlets and JSPs to upload and retrieve multimedia data. I have found that it is much more performant in Internet Explorer (5.5) than in Netscape Communicator (4.7). In fact, I cannot upload images larger than 10K at all using netscape. However, the same image can be uploaded into the same application using IE. Is this a known issue?
    Thanks in advance.

    Hi,
    We have successfully uploaded multimedia data in the giga-byte range (Quicktime and AVI files) at the same speed with both the Netscape (4.7n) and MS IE (4.n and 5.n) browsers. One thing we have noticed is that its very important to set the manual proxy settings correctly if you have an environment with a proxy server. If you don't, then uploads can go via the proxy server and, for some reason, that seems to take considerably longer. For example, suppose you are in the www.xyzco.com domain and are connecting to a host named webserver.www.xyzco.com, then specify webserver and webserver.www.xyzco.com (to cover both cases) in the "Do not use proxy servers for..." box in the manual proxy server configuration screen. Also, if you're using a tool such as JDeveloper that uses the host IP address in the debugger environment, then you also need to add the numeric-based (nnn.nnn.nnn.nnn) IP address to this list.
    Hope this helps.
    In order to better understand the variety of ways in which our customers are using interMedia, we'd be very interested in knowing a little more about your application, the interMedia functionality that you are using, and how you are developing and deploying your application. If you are able to help us, please send a short email message with some information about your application, together with any comments you may have, to the Oracle interMedia Product Manager, Joe Mauro, at [email protected] Thank you!
    Regards,
    Simon
    null

  • Three questions about Java and Ftp

    Hello, i've the following questions about Java and Ftp:
    1- .netrc file is in $HOME directory but i can't access to this directory from java code. The following line producesan Exception (directory doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");
    2- .netrc file must have the following permissions: -rw- --- --- but when i create the .netrc file the following permissions are on default: -rw- r-- r--, how can i change this permissions? (In java code, i can't use chmod.....)
    3- Are there any way to pass parameters to a .netrc file? If i get to do this i needn't change the permissions because i can't modify or create/destroy this file.
    Thanks in advanced!!!
    Kike

    1- .netrc file is in $HOME directory but i can't
    access to this directory from java code. The
    following line producesan Exception (directory
    doesn't exists)
    FileWriter file = new FileWriter ("$HOME/.netrc");$HOME would have to be replaced by a shell, I don't
    think you can use it as part of a legal path.
    Instead, use System.getProperty("user.home");
    Ok, thanks
    2- .netrc file must have the followingpermissions:
    -rw- --- --- but when i create the .netrc file the
    following permissions are on default: -rw- r--r--,
    how can i change this permissions? (In java code,i
    can't use chmod.....)Yes, you can: Runtime.exec("chmod ...");
    I need to use estrictly the .netrc with -rw- --- --- permissions
    Yes, i can use Runtime.exec ("chmod ..."); but i don't like very much this solution because is a slow solution, am i right?
    3- Are there any way to pass parameters to a.netrc
    file? If i get to do this i needn't change the
    permissions because i can't modify orcreate/destroy
    this file.I don't think so. Why do you need the .netrc file in
    Java at all? Writing a GUI frontend?I want to use automatic ftp in a java program and FTP server, the files and path are not always the same, so i can:
    - modify .netrc (for me is the complex option)
    - destroy and create a new .netrc (is easier but i have permissions problem)
    - use .netrc with parameters but i haven't found any help about it
    Thanks for your prompt reply!!!!
    Kike

Maybe you are looking for

  • ITunes and sound check

    I updated to iTunes ver 7.1.1.5 recently. I have a problem with "Determining Song Volume" of all my library every time I open iTunes. It uses 100% CPU until I stop it. I have already UNCHECKED Sound Check, that didn't seem help. I reinstalled it agai

  • How to include Quality Mgt View - Inspection Setup- InspType and Active

    Friends, I am working on MM data conversion. I am using STD RMDATIND program for this. I need to update fields in View Quality management, Inspection Type and Active check box. We could achieve this through Quality management -> Inspection Set up->cl

  • How to install ABAP as a backend system in my EHP1

    I have successfully installed EHP1 composition enviornment from SDN , now i m able to work on NWDS for JAVA and Enterprise portal . it contains java application server . but in order to get data from ABAP Backend system from NWDS(JAVA) , I don't have

  • Reader version 9.4.4 update keeps coming up

    I have Mac OSX 10.6.7 and Adobe Reader version 10.0.3 but I keep getting an update reminder for 9.4.4. I have updated this and I alays cancel but everytime there is an Adobe update this one also appears. What do I do?

  • Render queue waits for FTP upload

    I Googled this issue and looked it up in this forum, and surprisingly found nothing. When using the feature for automatically uploading an exported file to an FTP server, Adobe Media Encoder renders 1 file, uploads it, and meanwhile the rest of the r