Confusion building servlet

Hi friends, I really need your help.
I have an html file saved on my PC. my assignment is to construct a Servlet that will read the info entered by the user when he clicks the submit button.
I know this!!!!
Now, I'm using netbeans and I created a web application which also created an index.jsp file in the project.
So my question is should I copy paste the html code from the file i have saved on my pc to the index.jsp? and then work from the index.jsp file?
Or should I create a servlet and somehow link it to the HTML file that i have saved in my PC?----don;t know how to do that
Or should I bring the saved html file into the netbeans project?
Please i need your help, i need an explanation on what to do?

Here is how I would suggest you approach this problem:
* Using your favorite IDE such as Eclipse, create a web application that has a single Hello World JSP file (ie, it says 'Hello World') and deploy it. In its <form> tag put action="". This means when a submit button is clicked in the form tag, it will be submitted back to itself. Verify this works.
* Using your favorite IDE such as Eclipse, create a servlet in that web application that when it receives a url request (that is, you type in the url of the servlet directly in the browser), it will display 'Hello World' on the user's browser (this has nothing to do with the JSP file) . In order to get a url request coming from the browser to the servlet, you have to alter the web.xml file such that is has a <servlet> and servlet map tag in it that specifies the servlet you created.
* In the JSP file, within the form tag, alter the action attribute so it references the servlet. Then, alter the servlet so when it receives the request, it submits back to the JSP page via request dispatch function.
Note the JSP file, when called, generates HTML tags and sends it to the browser. Therefore your HTML file on the browser is equivalent to what the JSP file generates. You should be able to alter the HTML file so its form tag's action attrribute points to the servlet. Alter the servlet so it submits to the HTML file instead of the JSP page.
You can forget the index.JSP file.

Similar Messages

  • Dynamically Building Servlets

    I have recently written a java based script pre-processor, taking a HTML page and converting it into a servlet which can then be run in a servlet container.
    My question is how can I build a servlet to compile and run the HTML page, much in the same way as JSP?
    Any pointers would be appreciated...
    Fahim

    Could you maybe explain why you need to convert an
    HTML page into a servlet? For the life of me I can't
    see why you would need to do this.The page includes server tags as well as HTML, these will not work on the client without processing from the server.
    >
    The HTML will get to the browser whether you feed it
    through a servlet or not. If its not dynamic, why
    create the additional overhead of a servlet just to
    get the content to the browser? (Not to mention the
    coding you did to write the "pre-processor").To automate the preprocessor. Currently I have to...
    * Write the server page
    * Preprocess the server page
    * Compile the servlet
    * Copy to Web Root
    * Test
    I want to get rid of the middle three steps.
    >
    I can think of a pre-processor that does the exact
    same thing but only requires about 4 lines of code, it
    takes the extension of the *.html file and changes it
    to *.jsp. Voila! Put that puppy in a servlet engine
    and instant servlet! :-)No... I don't think so. It is not a simple matter of converting to JSP.
    >
    Seriously though, I am curious as to why on earth you
    would need to do this.I hope the above explains why I want to do this.

  • Confusion building JTree from path strings

    If I have a bunch of strings like this:
    "/dira/dir1/file1"
    "/dira/dir1/file2"
    "/dira/dir2/file1"
    "/dira/dir3/anotherdir/file1"
    etc.
    Does anybody have an easy solution to getting them in a JTree that looks like this:
       dira
        |
        +-dir1
        |  |
        |  +-file1
        |  |
        |  +-file2
        |
        +-dir2
        |  |
        |  +-file1
        |
        +-dir3
           |
           +-anotherdir
              |
              +-file1Mainly I am having trouble getting the tree to populate without duplicating nodes. For example dir1 gets listed twice. I am looking for a solution that will parse these strings and build the tree. I have found demos that read a file system, but nothing that works with strings. I have tried to pick apart the file system demos, but so far I can't get it to work correctly.
    Thanks,
    Jeff

    This compiles and works (with 1.4):
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.HashMap;
    public class TreeStrings extends JFrame {
        public TreeStrings() {
            super("Tree strings");
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setSize(500, 400);
            String[] inputStrings = {"/dira/dir1/file1", "/dira/dir2/file1", "/dira/dir2/file2"}; // your bunch of Strings     
         DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("www");
         HashMap nodeMap = new HashMap();
         for(int i = 0; i < inputStrings.length; i++) {
             String s = inputStrings;
         DefaultMutableTreeNode lastNode = rootNode;
         int lastIndex = 0;
         while(true) {
              DefaultMutableTreeNode tempNode = null;
              int nextIndex = s.indexOf("/", lastIndex + 1); // <- i forgot + 1
              if(nextIndex != -1) { //we are somewhere in middle of s, checking nodes from root to leaf, one by one.
         String nodeKey = s.substring(0, nextIndex);
         if(nodeMap.get(nodeKey) == null) { //no such node, must make one
              String nodeName = s.substring(lastIndex, nextIndex); // you want the last nodeKey word for node name
         DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(nodeName);
         nodeMap.put(nodeKey, newNode);
         lastNode.add(newNode);
         lastNode = newNode;
         else { //allready such node, just put it to be lastNode
         lastNode = (DefaultMutableTreeNode) nodeMap.get(nodeKey);
    lastIndex = nextIndex;
         else { //no more "/" , it means we are at end of s, and that all parent nodes for this leaf-node exist.
         // and we just add the leaf node to last node
         String leafName = s.substring(lastIndex, s.length());
         DefaultMutableTreeNode leafNode = new DefaultMutableTreeNode(leafName);
         lastNode.add(leafNode);
         break; // go to next s
         //You first make your tree structure with DefaultMutableNodes,
         //Then make a DefaultTreeModel with the root node,
         //Then make a Tree with the DefaultTreeModel
         DefaultTreeModel treeModel = new DefaultTreeModel(rootNode);
    JTree yourTree = new JTree(treeModel);
    getContentPane().add(yourTree, BorderLayout.CENTER);
    show();
    public static void main(String[] args) {
         new TreeStrings();
    Anything else?

  • "constructor not found" error when building servlet

    Greetings,
    We are encountering the following error when trying to make or run a project that displays a simple crosstab as a servlet:
    Error(45,9): constructor ServletRenderingContext(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.ServletConfig) not found in class oracle.cabo.ui.ServletRenderingContext
    Clicking on this error brings you to the following lines of source in ApplicationRenderingContext.java:
    super (request, response, servlet.getServletConfig() );
    Can anyone assist?
    Regards,
    Steve Locke

    This happens in JDeveloper; can't deploy due to this error.
    Here's my version info:
    BI Beans Diagnostics(v1.0.0.0) 4/15/04
    ===============================================================================
    JDEV_ORACLE_HOME ............................. = c:\oracle\ora92
    JAVA_HOME .................................... = c:\oracle\ora92\jdk
    JDeveloper version ........................... = 9.0.3.3.1205
    BI Beans version ............................. = 9.0.3.6.0A
    BI Beans internal version .................... = 2.7.0.13.1
    Connect to database .......................... = Successful
    JDBC driver version .......................... = 9.2.0.3.0
    JDBC JAR file location ....................... = c:\oracle\ora92\jdbc\lib
    Database version ............................. = 9.2.0.4.0
    OLAP Catalog version ......................... = 9.2.0.4.1
    OLAP AW Engine version ....................... = 9.2.0.4.1
    OLAP API Server version ...................... = 9.2.0.4.1

  • The walkthrough of building DB servlet doesn't work for me?

    I download JDeveloper2.0 a few days ago and tried to build
    servlet following the instruction from this web site. But the
    sun web server complaint not being able to find the file I
    specified. It seems the servlet's .class file need to be copied
    to the c:JavaWebServer1.1.3/servlet directory. But even after I
    did that nothing improves. Can anyone help?
    by the way, I tried the building DB applet by using
    JDeveloper1.1. The example i used is on Oracle Press's
    JDeveloper book(pg384). After I deploy it on the web using
    OAS4.0, if I call it using Netscape, it says query failed. If I
    call it using IE, sometimes it works fine, and other times not
    (applet doesn't show up). I am a bit of disappointed about the
    product,since I was thinking about using it to develope our
    database's web interface.
    Steve
    null

    Steve,
    I would recommend using the instructions in the online help for
    deploying the servlet. The online demos are not really intended
    to be step by step tutorials, and are also not as up to date as
    the online docs, which are much more detailed.
    In the online help system, expand the Developing Web Applications
    node, then Deploying Java Servlets, then Deploying a Database
    Servlet.
    L
    Steve Chen (guest) wrote:
    : I download JDeveloper2.0 a few days ago and tried to build
    : servlet following the instruction from this web site. But the
    : sun web server complaint not being able to find the file I
    : specified. It seems the servlet's .class file need to be copied
    : to the c:JavaWebServer1.1.3/servlet directory. But even after I
    : did that nothing improves. Can anyone help?
    : by the way, I tried the building DB applet by using
    : JDeveloper1.1. The example i used is on Oracle Press's
    : JDeveloper book(pg384). After I deploy it on the web using
    : OAS4.0, if I call it using Netscape, it says query failed. If I
    : call it using IE, sometimes it works fine, and other times not
    : (applet doesn't show up). I am a bit of disappointed about the
    : product,since I was thinking about using it to develope our
    : database's web interface.
    : Steve
    null

  • Problem while building jsp/servlet  in j2me

    Hi friends,
    I'm building Servlet in j2me.When i run this Servlet on web browser the Servlet running fine.But while in application when i used
    conn = (HttpConnection)Connector.open( url );
    where url = "http://localhost:8080/servlets-examples/hits"
    It hangs ,the debugger stuck at this method .It didn't throw any Exception also.
    Whats the problem?how could i resolve this issue?
    Note:
    I've used the follwing tutorial
    http://developers.sun.com/techtopics/mobility/midp/articles/tutorial2/
    to build servlet in MIDlet.
    Regards,
    Sachin Warang.

    hi friends,
    I debug the code while doing so i realised that it throwing SecurityException .So edit the preferences>
    where in security i've change it to untrusted and restore the settings.
    After clicking on OK .
    The application works fine.
    Regards,
    Sachin Warang.

  • Converting servlets output to PDF fle

    How to convert Java Servlets output html file to PDF file or a Word document.

    not sure what u mean by 'convert' the output to PDF or word document
    Do you mean you want to force the browser to open file using MSWord / PDF viewer? If yes :
    For showing output as a word document, you can set the servlet response MIME type to 'application/ms-word' and set its extension to .rtf . You can then use a RTF template to build servlet output (since RTF is flat file format). By replacing placeholder tags in RTF template, you can generate content.
    For showing output as PDF, you'll need some library for PDF writing.
    hth,
    Subodh

  • Role Of Servlet when we have Tag Library ?

    Hi all,
    I am little bit confuse about Servlet Role.
    I have been working in a IT (dot com) compnay in India for the last one year. I have developed Program for the Projects and worked in Modules.
    When I joined the company we followed MVC (Model View Controller) Architecture, and technology we had use-------- JAVA, JSP,Servlets,Java Bean,JDBC.
    But now we are working on Tag Library (Custom Tags) . And our total work is shifted to Tag Library Architecture.
    Now, there is no use of Servlet in our Modules and or program except for Login and Password Authentication/Verification.
    So I want to know that What is the role of Servlet in the current scenario when we have Tag Library (an excellent feature, code reusablity, fast,less coding in JSP,separate design from coding,separate tag handler class for each tag).
    Why do we use Servlet-JSP-Bean Architecture when we have Tag Library
    Please guide me to the right direction.
    Thanking You!
    amitindia

    If I understand JSP model 2 architecture (MVC) role of custom tag is to support presentation layer. Construction of tag classes is coupled with data presentation also data flow in custom tags is connected with atributies, tag body etc. Also tasks such a security validation should be rather done in filters then in custom tag, becouse it depends then on puting tag in page source.
    In fact each approach (if working:)) is good.
    In real world real logic should be implemented in business objects layer and then need for servlets is limited to one controller servlet. And I believe servlets are best in this role. And with this approach use of TLs is in fact limited to presentation support.

  • NIM game servlet help...

    I'm trying to make a NIM game servlet for class, but i'm having trouble with it.
    It's supposed to have a main pile of 21 'sticks' and the player can draw 1-3 sticks, there is a computer player too. so i have to make something simple with radio buttions for 1,2 or 3 sticks and then the servlet does that computation, plus the computer players. In the end the person who can't draw a stick loses...
    I assume i have to make an html front end page with the parameters, then have a hidden variable or cookie keeping track of the pile?
    I know java applets, but I get confused with servlets... any help would be great, thanks.
    jon.

    servlets are on server-side (in opposite to applets).
    maybe you have a look at pdf.coreservlets.com where you can download a really good ebook for free. it gives you a introduction to servlets on how to use it.

  • Servlet for WS

    hi everyone, I am building servlet web client for simple axis web service. I am staying behind because of this problem is there anyone who can help me!?
    thanks a lot!
    here is error that tomcat reports me:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.axis2.AxisFault: Connection refused: connect
    org.apache.axis2.AxisFault.makeFault(AxisFault.java:417)
    org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:195)
    org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
    org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
    org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
    testws.doo.ws.NarudzbaServiceStub.posaljiNarudzbu(NarudzbaServiceStub.java:190)
    www.narucivanje.serv.NarudzbaServlet.doPost(NarudzbaServlet.java:123)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.net.ConnectException: Connection refused: connect
    java.net.PlainSocketImpl.socketConnect(Native Method)
    java.net.PlainSocketImpl.doConnect(Unknown Source)
    java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    java.net.PlainSocketImpl.connect(Unknown Source)
    java.net.SocksSocketImpl.connect(Unknown Source)
    java.net.Socket.connect(Unknown Source)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    java.lang.reflect.Method.invoke(Unknown Source)
    org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:139)
    org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:124)
    org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:706)
    org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1321)
    org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:386)
    org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
    org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
    org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:520)
    org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:191)
    org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
    org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
    org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
    org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
    org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
    org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
    testws.doo.ws.NarudzbaServiceStub.posaljiNarudzbu(NarudzbaServiceStub.java:190)
    www.narucivanje.serv.NarudzbaServlet.doPost(NarudzbaServlet.java:123)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    root cause
    java.net.ConnectException: Connection refused: connectThis means that the connection cannot be acquired in any way. Thus either hostname/IP and/or the port is incorrect, or there is a firewall/proxy in between which blocks the connection.

  • BI Beans Samples Problem

    Hi,
    I've installed BI Beans samples and they are working fine except servlet samples.
    Only bootstrap servlet example is working fine but other servlet samples generates errors. Custom query tool shows crosstab, but when i try to drill down, or try to change time and press go, then a got javascript error Object expected.
    In page source I can find link to javascript src file MarlinCoreA4.js, but a can't find this file on my HDD.
    Have any ideas.
    Thx.

    I would recommend upgrading if possible to JDev/BI Beans 10g as this new release has a lot of cool new features that make development a lot faster and easier. Included in JDev/BI Beans 10g Help System (this might also be present in the 904 documentation - sorry I cannot remember) are topics that should help you develop your servlet application.
    The Help system provides working code for the following areas:
    Building Servlet Applications
    Rendering HTML pages
    Handling thin beans events
    Using thin bean dialogs
    Preparing a dialog or wizard page in a Servlet
    Adding a graph or crosstab wizard to a Servlet
    Adding a PresentationBuilder to a Servlet
    Adding a Graph or Crosstab Wizard to a Servlet
    Adding a Presentation Wizard Page to a Servlet
    Managing state information
    Managing thin presentations
    Hope this helps
    Business Intelligence Beans Product Management Team
    Oracle Corporation

  • Bridge 5 continually recreates rebuilds cache

    Because my primary hard drive was getting full, I recently changed the location for cache files to an alternate drive.  (I did this through Preferences>Cache>Location.)  I deleted the old cache, and checked to make sure the new cache was being generated where on the alternate drive.  But now after every time I close and then re-open Bridge, all the files in any given directory have to be rebuilt.  I have waited to make sure all the "extractions" have been completed in a directory before closing Bridge.  But when I later re-open Bridge, all those images have to be re-created.  Since I have hundreds of files in any given directory, it takes quite a while to generate all the previews, only to need to repeat the process next time around.
    Is the change of cache directory related to this problem?  More generally, how do I get Bridge to stop re-creating previews each time I re-open a directory?
    Any help would be greatly appreciated!

    I did not mention this before as not sure it relates, but just just to make sure you are not confusing building cache with indexing.  If you do a search with include non-indexed files checked it will re-index your whole library even though it is already indxed.
    I would definately use the edit/preference/compact cache to get rid of orphaned thumbnails.  If you have not done it for awhile it will really recduce the cache size.  The Mac forum recommends not to use the purge cache here, but use Tools/cache/purge cache for xxx folder.  This is probably better as the general purge will not purge cache in the distributed folders you are building.
    Purging cache is recommended in case you have a contaminated thumb that is causing problems.
    Also look at that thumbnails.  If there is any file that has an icon rather than an image look at name and file closely as it may be corrupt.  This only applies to file extentions that normally display thumbnails.
    I use the fast option of embedded thumbnails so it takes a few seconds to rebuild 800 or so thumbnails.  Do not know how long it would take with HQ thumbs.

  • Forwarding requests with JServ

    I have written a servlet that I would like to forward a request to a new page after doing some processing. However, I get ClassNotFound/MethodNotFound exceptions from JServ. I checked the documentation and found that JServ only supports the 2.0 Servlet Specification and I figure the RequestDispatcher interfaces I am trying to use are part of the Servlet 2.1 or 2.2 specification. I tried to set up Apache to run Tomcat, but I must have done something wrong in the setup because when I try to start Tomcat/Apache, Apache bails. Is there another way to get around this, so that my JSPs and servlet do what I want them to do. Also, does anyone know what/where mod_ose is and where/how to get it and make it run with Apache.
    Any help will be greatly appreciated.

    Hi you can use Odyssy calasses(cos.jar) to call the Servlet/Jsp from servlet. Thease classes are build on top of Servlet API 2.0. This is just for now. In the upcomming version Apache Jserv comming with servlet API 2.2.
    mod_oes is having Oeacle build servlet engine support fully Servlet API 2.2.

  • How do I use the JSDK to build a servlet?

    I've just about given up on this. I've now spent all day downloading files and programs and viewing web pages for help. All I want to do is compile a simple servlet. My previous JDK couldn't do this.
    Can anybody tell me (in plain english) what software I need and how to set it up so I can build a servlet?

    Download a proper IDE like Netbeans (www.netbeans.org). You get an integrated Tomcat servlet engine with it which will be good enough to start with.
    Silvio Bierman

  • 10/14/2014 - Release - AIR 15 Runtime and SDK - build no. confusion

    the latest release build of AIR15.0  10/14/2014 appears to be exactly the same build as the one released on  10/02/2014
    both downloads give AIR 15.0.0.302 ---  is this an error .... ?
    its all getting very confusing ...
    was expecting a new build number for the latest release 10/14/ , updated docs etc ?

    Sometimes the release version has a later build number than the last beta we received, which in a way can be even worse than if the build is the same. The thing that has caused some confusion is that a few posts here have been answered with "we've fixed that and it will be in the next build", and the next build turned out to be the same as the previous build.
    So, I think the truth is that those things are fixed in the next build that appears on labs, and the release one doesn't count as a new beta build. I don't know when the next labs build will be.

Maybe you are looking for