Basic Help on Servlets

Hi,
I have installed JDK1.4.0_01 and Tomcat 4.1.
In my basic Servlet Example, I have created the following directory structure --
TOMCAT_HOME\webapps\testing\index.html
TOMCAT_HOME\webapps\testing\src\TestServlet.java
TOMCAT_HOME\webapps\testing\WEB-INF\web.xml
TOMCAT_HOME\webapps\testing\WEB-INF\classes\TestServlet.class
The HTML Takes some input from a Text box and on Submit, calls the Servlet.
The problem I am facing is that, everytime the Submit is invoked, it gives HTTP 404 Servlet Not found Error.
My entries in server.xml ---
<Context path="/testing" docBase="testing" debug="0" reloadable="true">
     <Logger className="org.apache.catalina.logger.FileLogger"
          prefix="localhost_testing_log." suffix=".txt"
          timestamp="true"/>
</Context>
My entries in web.xml ---
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
     <url-pattern>/testing</url-pattern>
</servlet-mapping>
</web-app>
In the POST tage in the index.html, I am calling ---
<form action="TestServlet" method="POST">
</form>
http://localhost:8080/testing displays index.html appropriately.
But, on SUBMIT, HTTP 404 Error is displayed.
Expecting Help!
Thanks in Advance

According to your servlet mapping , the url to run your servlet is :
http://localhost:8080/testing/testing !!! because of <url-pattern>/testing</url-pattern>
so change it to :
<url-pattern>/TestServlet</url-pattern>

Similar Messages

  • Darwin Streaming Server (really basic help)

    Hey, I need some basic DSS help. REALLY basic help. So, Darwin is installed and everything, and I can upload movies to the /usr/local/movies directory. When I upload them there, I can see them in the 'make new playlist' screen. However, Darwin seems to be requesting a .sdp file as the 'mount point'?? What's with that?
    Thanks for any assistance.

    The mount point is supposed to be the location on the hard disk where the movie file resides; the sdp extension indicates that the file is a stream. To create a SDP file, try using the information linked to from this page.
    (14906)

  • Jasper basic help

    hello all,
    I need some basic help and info on jasper. if some one has used it and used it specially with swing, please let me know.
    I need some basic concepts of jasper.
    1: can I send the reports to the printer directly? i mean, is there a class in jasper to access printer.
    2: can I send queries directly to a report?
    3: if there is facility to send the report to printer, then can I preview the report page wise before sending it to the printer?
    Please provide some prompt info as I am in a big trouble with a project and I don't have a lot of time to go through all the docs, just to find that there is no direct printing support. if there is printing support in jasper then I will spend the time on the docs.
    thanks in advance
    Krishnakant.

    1: can I send the reports to the printer directly? i mean, is there a class in jasper to access printer.
    yes
    2: can I send queries directly to a report?
    you query the database, create the report using the query and then print it.
    3: if there is facility to send the report to printer, then can I preview the report page wise before sending it to the printer?
    yes you can display the report on the screen
    Basically you can display a report on the screen or print it directly.
    If the report is displayed on the screen you then can print or export it.
    These may help
    http://www.javaworld.com/javaworld/jw-09-2002/jw-0920-opensourceprofile.html
    http://jasperreports.sourceforge.net/quick.how.to.html
    http://jasperreports.sourceforge.net/samples/index.html
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=64&t=000465
    http://sourceforge.net/forum/forum.php?forum_id=113530
    Here is an example pulled from my code that displays a report on the screen.
    It is not going to be much help.
    Note the references to JDesktopPane and modalFrame will be confusing.
    The report is loaded from a jar.
    I go to a lot of trouble to trap the report on a modal screen.
    processStandardReport("sreports/employees.jasper", null);
    public static boolean processStandardReport(String reportFile, HashMap controlHash) {
       JasperPrint report = null;
       URL fileURL = null;
       String rFile = reportFile;
       HashMap rptHash = controlHash;
       // get report reference
       try{fileURL = startup.class.getResource(reportFile);}
       catch (Exception jEX) {
          // Unexpected error
          return false;
       Connection reportConnection = ???? // H E R E   establish your connection
       try{
          // set file stream
          fs = (InputStream)(startup.class.getResourceAsStream(rFile));}
          // load the report
          JasperReport template = JasperManager.loadReport(fs);
          // fill the report
          report = JasperManager.fillReport(template, rptHash, reportConnection);
       catch (Exception jEX) {
          // Unable to process report
          // RELEASE OR CLOSE YOUR CONNECTION
          return false;
       // RELEASE OR CLOSE YOUR CONNECTION
       try {
          // set uo to display the report
          int iPtr = rFile.lastIndexOf(".");
          String title = "View Report "+rFile.substring(0,iPtr);
          JDesktopPane desktopRef = getDesktopReference();
          JRootPane rootRef = desktopRef.getRootPane();
          JInternalFrame modalFrame = new ModalInternalFrame(title, rootRef , desktopRef){
             public void dispose() {
             ModalInternalFrame.killModalFrame();
             ReportUp = false;
       ReportUp = true;
       // display the report in modal panel
       // note this is a subclass of JPanel
       JRViewer jrv = new JRViewer(report);
       jrv.setPreferredSize(new Dimension(600, 410));
       JScrollPane reportScroll = new JScrollPane(jrv);
       JPanel viewer = new JPanel();
       viewer.add(reportScroll);
       modalFrame.setFrameIcon(frameIcon);
       modalFrame.setClosable(true);
       modalFrame.setSize(new Dimension(625, 450));
       modalFrame.setPreferredSize(new Dimension(625, 450));
       modalFrame.setMinimumSize(new Dimension(625, 450));
       modalFrame.setLocation(50, 50);
       modalFrame.getContentPane().add(viewer);
       modalFrame.pack();
       modalFrame.setVisible(true);
       catch(Exception vEX){
          // unable to view report
          return false;
       return true;
    }rykk

  • Basic help with photo slideshow?

    Hi
    I am new to adobe after effects and I have recently purchased a file from videohive (http://videohive.net/item/photo-album-v2/44575) which is great.  I am trying to tweak it a little and as I am new to after effects, I would love to ask anyone for some basic help?  I will be leaving the country in 2 weeks to get married and my UK wedding reception will be a week after I return so I am in pretty much a hurry to get a slideshow rendered and put onto dvd to play in the reception.  I have mastered how to render in PAL format and get onto DVD but I am having a little trouble with basic elements such as adding keyframes.
    The file has 13 placeholders which I have replaced with my own photos. Two of which are replaced with avi videos instead of jpg. This works fine but I would like to stop the camera movement on say photo 7 and zoom in a little on the video, play the video (approx 40 seconds) then return the photo back in place and resume your camera movement.  This will be repeated for one other photo (photo 9) where the video is approx 60 seconds.  Could you possibly help me how I can do this?  I am also adding music to play throughout from start to finish and I would also like to pause (or fade volume) whilst the avi video placeholder is playing, then resume after playback.  I know this may sound a lot to ask but I know that with the knowledge - it will only take me about 30 mins work once I know what to do.  Any help you can offer will be fantastic. I am proficient with Adobe Flash so I understand the jargon of timelines etc.
    Thank you for any help anyone could provide in my panic to get complete.
    Best regards
    Sean.

    *woohoo* Here's to the ones daring marriage... For your  problems there is a number of ways to tackle them, but the specific solution may depend on how the template works. As David already said, for audio you'd be better off using Premiere, but assuming you have just a single track that realyl only requires fades, AE should serve your needs. You can reveal the audio volume by tapping the L key when the respective layer in your composition is selected, then enable the stopwatch icon to add keyframes. Layers can be trimmed by simply dragging their ends, duplicated with Ctrl+D and split by using Ctrl+Shift+D, so it should be perfectly possible to extend your audio as needed, assuming you increase the comp duration first via the composition options. For the images to come into view, you could simply scale them up. Of course the project is based on 3D layers, so it would look a lot better if you animated the camera to dolly in, but if you have no experience in AE, that may make more of a mess than it's worth. Therefore I simply recommend you create a photo flash/ film burn transition - add a  white solid with a slight color tint, set it's blending mode to add, animate it's opacity and while it's fading out, fade in your full screen video. If done in 32bpc, this can look quite real and since it's a separate effect, it won't interfere with the rest of the animation.
    Mylenium

  • Need basic Help - SG300 with vlan and routing

    Hi,
    i need some basic help with configuring vlan/routing.
    Situation:
    DSL Router - Cisco 300 - XenServer
    192.168.1.253 - 192.168.1.19 - 192.168.1.10 (mgmt ip)
    goal is, to reach from inside xenserver vms the internet.
    vms = 192.168.2.x
    gateway ip = 192.168.2.1
    what i did:
    - configured vlan 102, tagged, with the xenserver port
    - configured on xenserver a network with vlan id 102, attached to the vm
    - this network is conntected to an external bond
    - configured ipva4 interface: vlan102 - Static - IP 192.168.2.1 (this is the gateway ip of the vms)
    - automatic configured IPv4 Route: 192.168.2.0/24 next hop 0.0.0.0, Directly connected
    So at the moment i cant ping from inside a vm to the DSL Router (192.168.2.2 to 192.168.1.253)
    any ideas what i misconfigured or whats wrong?
    cheers,
    -Marco

    Hi Tom,
    ok, that make sense. I can ping the router now inside vms from 192.168.2.x network.
    But i cant ping external adresses, error: Destination net unreachable.
    My other problem i have, i cant reach any server from outside over router portforwarding.
    How do i have to configure the upload port to the dsl router? Is it a access port or a trunk
    port with all vlans (tagged or untagged?) At the moment ive a tagged Trunkport with all vlans.
    IPv4 Interface Table
    Interface
    IP Address Type
    IP Address
    Mask
    Status
    VLAN 1
    Static
    192.168.1.19
    255.255.255.0
    Valid
    Should the VLAN1 ip adress not the router ip adress ? Do i need an additional vlan for
    the router ? At the end i like to change the switch ip from dhcp to static (change automaticly
    when switching to layer 3 mode), but ive to look for the ios commands first.
    What else do i missing ?
    Thanks a lot,
    Marcus

  • Pleeeaaseeee Help - Basic authentication with Servlet

    All,
    A user from my site is allowed to access another site that requires Basic Authentication(apache). This is what I have done in my servlet, but does not work:
    String userpwd = "username:pwd";
    response.setHeader("Authorization", "Basic " + userpwd);
    response.sendRedirect("http://155......." + "username=" + userID);
    Both IE and netscape browsers still prompt for username and pwd window. Is this correct???
    --Kawthar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I'm assuming that you are attempting to bypass the sign-on prompt from the other site. What you will have to do is access the other site from within your servlet and foward the content to the user. In other words, you would be setting your servlet(s) up as a proxy. This can become rather complex as you may run into the need to handle cookies and such from your servlet. Another alternative, if you can modify the remote site, is to set up the other site to accept some sort of keyword or password that your servlet can include in the URL string which would bypass the initial signon.

  • Need Urgent Help with Servlets!!!

    I was just assigned a java project few days back and the thing is that i noe nuts abt JAVA!!! My first time and i admit i'm a slow learner.
    I was tasked to develop a servlet for web based query of inventory status in FIFO storage from QIS database.
    Basically, i heard according to my supervisor that this is a very simple project that may be completed in just days..but as i said this is my first Java program and i really need u guys to help me!!!! I have no idea how to start the entire coding process.
    The main page where the option buttons are is actually a form. This program have a HTTP extension i think. Below i have indicate the System and User Requirements.
    System Requirements
    * A Servlet
    * 2 option buttons
    * 1 for retrieving a Summarised Report
    * 1 for retriveving an Detailed Report
    * 1 command button for retrieval of data
    * Retrieved data will be displayed on another frame
    User Requirements
    * Be able to view Summarised Report at a click of a mouse
    * Be able to view Detailed Report also at a click of a mouse
    PLS HELP!!!!!!!!

    Justa comment...
    << according to my supervisor that this is a very simple project that may be completed in just days
    If your supervisor is so confident, then, maybe he/she should just get it done himself/herself. I really mean it. However, if that does happen, he/she should provide post-implementation support himslef/herself.
    In the meanwhile you can continue thinking about doing it the right way. Which is to first get some grasp of sorts about the various Java and other technologies and concepts you are talking about. Then have some kind of plan and follow it.
    I think at the end both you, and more importantly, your supervisor would see the difference in the result with respect to quality of work.
    Forums such as these provide an excellent wealth of information mostly because they are a means to consolidate knowledge gained by individuals from their past experience.
    However, in my opinion, it would be wrong to expect that one would be able to design and implement a real-life application just from information gathered from such forums. An example problem if you do it that way is: who will provide guaranteed support if something does not work in your real-life application. Your supervisor ?
    Instead, do the study part systematicaly. Try to convince your supervisor that thats the way to do it. Then do it. And come back with specific problems you might have.
    Best luck.

  • MVC Design Help, Single Servlet, How do I access the Model and DB

    Hi all. New here and looking for some help.
    I am currently writing a website that allows the creation of users, that may upload articles and post comments on articles. Im trying to develop using MVC. I have a single controller servlet that processes POST actions throughout the site (eg. InsertArticle, DeleteArticle, ModifyArticle, etc..)
    Now my problem is, just how do I retrieve the articles from the database? .. for example, if I load up a page http://localhost/articles.jsp which should display all the articles currently in the site.. I would have a function say getAllArticles() which should return a collection of all the articles. I can then iterate through the articles in the jsp page.
    I am trying to use <jsp:useBean...etc.> BUT.. my articles bean constructor takes a databaseconnection object as a parameter. If I use useBean I cant pass the databaseconnection object to the bean and I get an error because it cannot create the bean.
    Any help on this would be appreciated as well as any tutorial links. I also looked at the petstore blueprint program on the sun website, but that program has me completely lost with all the xml. I would prefer not to use custom tags or struts for now. I would like to keep it simple with snippets of java code in the jsp pages for data retrieval and display while keeping all the business logic in the beans of the model. I would also like to keep this relatively secure. I am developing using Oracle Jdeveloper 10g.
    Thanks
    Jazz

    Hey steve, thanks for that.. but thats exactly what i
    dont want to do. I also realize that ive been writing
    the ejb's incorrectly to begin with and have begun to
    rewrite them. However maybe I can make it easier..
    what im trying to do is precisely what is in this
    diagram..
    http://gsraj.tripod.com/jsp/jsp.html
    the problem im having is where it passes data back to
    the jsp page.. entity beans cant (or shouldnt?) be
    accessed directly from jsp pages.. which means i
    create a session bean which interacts with the entity
    bean and can return information to the jsp page.. i
    understand what i have to do.. i just dont know how to
    do it.. been searching for google for tutorials and
    etc.. this site is the closest ive come but .. as you
    can see it says "more to come" ..
    thanks again guys really appreciate itAhhh. EJBs. Enterprise Java Beans and JavaBeans are two completely different beasts. I know nothing about EJBs, except:
    1) They are much harder to use (and serve a different purpose I assume) then JavaBeans
    2) Tomcat (the server I use) doesn't support them.
    Sorry I can't be of more help.

  • Can somebody Pls Help 500 Servlet Exception:

    I am rather new to java prog and have the following problem.
    How do I resolve?All I knw is that the resource bundle is not been read.Where do i go from there.Help!!!
    500 Servlet Exception
    java.lang.NullPointerException
    at ui.error__jsp._jspService(/SSO/ui/error.jsp:14)
    at com.caucho.jsp.JavaPage.service(JavaPage.java:74)
    at com.caucho.jsp.Page.subservice(Page.java:485)
    at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:179)
    at com.caucho.server.http.Invocation.service(Invocation.java:288)
    at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:132)
    error.jsp contains the following:
    <%@page language="java" session="false" import="com.infy.bbu.sso.common.SSOConstants, java.util.ResourceBundle, com.infy.bbu.sso.utils.SSOResourceManager, com.infy.bbu.sso.config.SSOConfig"%>
    <%@ page contentType="text/html; charset=utf-8" %>
    <%
    String langCode = request.getParameter(SSOConstants.PARAM_LANG);
    SSOResourceManager manager = new SSOResourceManager();
    if(SSOConfig.isEmpty()) SSOConfig.loadConfig();
    ResourceBundle rb = manager.getResourceBundle(application, SSOConfig.get(SSOConstants.SSO_RB_APP_NAME),langCode);
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title><%=rb.getString("SSO_ERROR_PAGE_TITLE")%></title>
    <script type='text/javascript' src='javascripts/ssodomain.js'></script>
    <script type='text/javascript' src='javascripts/SSOUIProperties_<%=langCode%>.js'></script>
    <link rel="stylesheet" href="sso.css">
    </head>
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="dummy" vspace="0" hspace="0">
    <tr bgcolor="#000000">
    <td height="22"><img src="images/adminbanner.jpg" width="353" height="52" vspace="0" hspace="0" border="0"></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td>
    <h1> </h1>
    </td>
    <td>
    <h1><br>
    </h1>
    <span class="tabletext"> <%= request.getParameter(SSOConstants.PARAM_ERROR_MSG)%><BR>
    <BR><a href="INFENG/LoginPage.jsp?<%=SSOConstants.PARAM_LANG%>=<%=langCode%>">Login</a>
    </span></td>
    </tr>
    </table>
    </body>
    </html>
    at com.caucho.server.http.ServletServer.serviceTop(ServletServer.java:937)
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:213)
    at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:158)
    at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
    at java.lang.Thread.run(Thread.java:534)
    Resin 2.0.5 (built Fri Jan 11 08:29:05 PST 2002)
    line 14 is in bold.

    sorry about that.It's just that I need to resolve
    this problem and need whatever help I can get.No. That is no reason for you to multipost.
    Do try and think about others sometimes. I mean really. Are you paying for support from this site? No. Then just be fucking patient please.

  • URGENT please help with servlets

    am using Jbuilder 3 and there is no servlet classs to import .imported JSDK and the javax files. but it keeps saying my class does not extend http servlet any ideas!!

    I've used JBuilder3 a few times and as far as I remember the default Target jdk (version 1.2) cannot be changed or ammended and so you can't really import javax.servlet stuff.
    Go to project -> properties.
    You probably just need to define a new jdk version call it "JDK 12 Servlets" or something. It'll prompt you most of the way and then you just need to edit the Class path and add the javax stuff.
    Alternatively you can just save the file with jbuilder and do the compiliation from the command line.
    Hope this helps.

  • I need basic help with my VISTA laptop. Adobe Reader X (10.1.4) IS INSTALLED BUT NOT WORKING.

    A basic questions. My laptop VISTA has Reader X (10.1.4) installed. Internet add ons has Adobe PDF llink helper enabled. I am not able to open PDF files?

    Moved to Adobe Reader.
    You cannot able to open pdf files on your computer or you cannot open pdf files in your webbrowser? If you cannot open pdfs in your browser, what browser are you using?

  • Flash CS5 Basic Help!

    I am very new to this program and am struggling to get past this one simple little thing!
    I clicked New > Action Script 3.0
    and am trying to do some of the basic tutorials and cant even get past the first one!
    I am trying to draw a filled in rectangle.... but even when i change the timeline button to fill instead of outline, it only ever draws the outline.
    Am i doing something wrong?
    Also i changed the background colour of the stage and it doesnt seem to change either....
    Please help me get past this first step in learning Flash!!
    I have been trying to follow the tutorials but everytime i try to draw a filled in shape on the stage, it always just comes out as an outline.  I have deselected the outline square so it is filled in... in the timeline an still i can only get an outline. I dont get it!!
    If you can see where im going wrong please let me know...
    Thanks

    I noticed what you said and what the image showed, but that's the best I could offer.  It doesn't look like you're doing anything wrong... the software appears to be having an issue.  Have you installed the latest update for CS5 (http://www.adobe.com/support/flash/downloads.html)?

  • Complete Novice Needs Some Basic Help

    Hi!
    I'm sorry to clutter up the discussion with such basic questions, but what I want to do is get something from a cassette tape to my iPod. I'm told I can do this through GarageBand, and I have an audio cable that the guy in the Apple store said I would need. I'm not even sure where to plug this cable in. So any help in where I plug this in, or what I do next would be tremendously appreciated. If someone could even tell me where to look for help that would be great (when I look in GarageBand help its saying something about MIDIs and I don't even know what that is). Eternal gratitude for any help....

    Oh man, this is frustrating and I might give up soon!
    So in System Preferences, Sound I have 2 things,
    Internal Microphone (port is Built-in) and Line In
    (port is Audio line-in port). I can't seem to
    select one or the other, they're just there.
    Yeah, there is no "apply" or "OK" or anything like that. Just click on the Line-In so that it is highlighted and close the system preferences. That takes care of that. My PB G4 automatically detects when I plug in my line-in now that it is set up.
    Then in GB preferences, I only have the option of
    Built-in Audio, there is no other option.
    Built-In audio is correct in GB prefs.
    I also couldn't find where you were saying to
    double-click...what's the track header? I've clicked
    everything and can't find a monitor drop down menu
    option.
    The track header is the left-hand side of the track where there is a small speaker or instrument. For what you are doing, you need to create a new basic track. (Under "Track" in the menu bar, click "New Basic Track") You should have a new blue track that is labeled "No Effects." Double click on the speaker image and a dialog box will appear. Right in the middle of this box there are options for Input, Volume, and Monitor. You can turn on and off monitor abilities here.
    On the plus side, the connector I have seems to
    work...its male/male 1/8".
    Perfect.
    Thanks again and if you want to bail out, I
    completely understand!
    Hang in there. We were once all newbies to this digital recording stuff too.

  • Help with Servlets!!

    Hi all,
    I need help with Java and Jsp. Here are the specs:
    1. An HTML web form that contains info about a customer: name, address, telephone number.
    2. When the "Submit" button is clicked, the information will go directly into an Oracle database table named "customer".
    Where should I start?? So far, I have created the HTML web form. So what i need is to write a servlet that will take the data from the web form and insert that into the Oracle table. If you have any solutions to my problem, please let me know. Thanks a lot in advance.

    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head>
    <title>
    Customer
    </title>
    </head>
    <body>
    <%!
    java.sql.Connection con;
    java.sql.PreparedStatement pstmt;
    java.sql.ResultSet rs;
    javax.servlet.http.HttpServlet request;
    String name,address;
    int phone;
    int i;
    %>
    <%
         try {     
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = java.sql.DriverManager.getConnection
    ("jdbc:odbc:<DSN name>","scott","tiger");
    %>
    <% } catch(Exception e){ System.out.println(e.getMessage()); } %>
    <%
    name = request.getParameter("name");
    address = request.getParameter("address");
    phone = Integer.parseInt(request.getParameter("phone"));
    pstmt=con.prepareStatement("insert into <table name> values(?,?,?)");
    pstmt.setString(1,name);
    pstmt.setString(2,address);
    pstmt.setInt(3,phone);
    i=pstmt.executeUpdate();
    %>
    </body>
    </html>
    1. create a dsn connecting oracle, using ODBC from control panel
    2. name the text fields in the html page as "name","address","phone"
    3. enter the table name you created in oracle in place of <table name>
    I hope this should work , let me know .......
    bye
    vamsee

  • Basic jsp and servlet question (JSP Model 2)

    Hi
    I want to make an website where i use JSP Model 2 architecture. However I got a basic question
    1. I need to separate business logic from presentation with the use of jsp and servlets. Meaning I want no html code in the servlet. Can you give a simple example of how this can be done? If I map my implementation of httpServlet to a jsp page in web.xml and override doPost() and doGet(). The calls to the jsp page comes to the servlet as it should. I want to process some methods (calling sessionbeans or similar which in turn calls entitybeans) and then show the jsp page.
    How do I show the jsp page without mixing html in the servlet as I've done below:
    doGet(HttpServletRequest req, HttpServletResponse res)
    PrintWriter p = response.getWriter();
    p.print("<html><body>Hello world</body></html>"); //I dont want to do //this, I want to display the JSP site
    doPost(HttpServletRequest req, HttpServletResponse res)
    //doSomething
    }Message was edited by:
    CbbLe

    You should treat your servlet class much like a controller, where you can then use JSP as the view. The way you achieve this is to use the forward() method in RequestDispatcher.
    Say you've got a servlet class org.yoursite.controller.YourController:
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
      //Set some value for use in the JSP file associated wth me
      req.setAttribute("greeting", "Hello world!");
      //Done with our business logic, off we go to the JSP file
      ServletContext app = getServletContext();
        RequestDispatcher disp;
        disp = app.getRequestDispatcher("/some/jsp/file.jsp);
        disp.forward(req, resp);
    }Now in your JSP file:
    <h1>Example</h1>
    <div>
      I just want to say <%= request.getAttribute("greeting") %>
    </div>Going to that servlet now executes business logic and then points to the JSP file for the view. You can forward from servlet to servlet too if needs be. The string you pass to forward() is whatever would be in the URI of the request so any <servlet-mapping> configurations in web.xml are used ;)
    There is some pretty in-depth documentation on the J2EE blueprints website, namely service-to-worker and front-controller patterns. I dare say if you're looking for this sort of code you'll want to look at the composite view pattern too (also on blueprints).

Maybe you are looking for

  • Bank Statement Import interface tables

    Hi all, I'm using OEBS R 12.1.3. Can anybody tells me/some links or info / about the Bank Statement Import Program which interface tables uses as i cannot found or i'm just a bad researcher...? I have to insert data there in order this program to cre

  • Mail displays a code when sending a picture from Photobooth. Any ideas ?

    Hello everyone, I have a problem since I bought my MacBook pro (Os X Lion 10.7.5) : When I am sending a picture from Photobooth by clicking on the "email" icon, the receipient of the mail can't see the picture but just a code. (For example : "ª◊} ÿåä

  • SOAP:14 - Unexpected element

    Hi, while trying to consume an external WS from our ECC 6.4 ABAP system, I'm getting the following error message: CODE - SOAP:14 ERRORTEXT - Unexpected element -el=script ns= More detailed information from RFC-Trace: XRFC> INFO 16:41:40: SOAP SESSION

  • Use properties file out of EAR

    HI All, Generally we create an EAR file with all the property files embedded in it. Here the problem is as and when we change the property files we need to build a new ear file and redeploy to J2EE stack. Is there any way that this properties file is

  • Doubt about Web Service Client

    Hi, I'm triyng consuming a WSDL file. When I create a Web Service Client with the URL of the WSDL, the compilation shows this message: init: wscompile-init: Created dir: C:\Documents and Settings\ooliveros\Mis documentos\NetBeansProjects\Selector1\bu