JSF vs. JSP and IDE Question

I'd like to get an opinion from the forum, I'm looking to build a web application that provides a front-end to a back-end, batch Java app. The back-end app has pre-existing common classes and methods with all of the essential business logic.
My first question is, what platform should I be looking at, Javaserver Faces or JSP? JSF is so new and all of the bugs surely haven't been worked out, but it is the heir apparent new direction of J2EE. JSP is a little more proven, but a little more difficult to work in. This "more difficult" might not be so bad for us, because we've developed most of our back-end app without an IDE or drag-and-drop tools.
My second question regards IDE's. I'm relatively new to OO programming, and I've never used an IDE. So, of the many free IDE's out there (Eclipse, Netbeans, etc.), are there any that you would recommend for your answer to the first question? How large of a process improvement would you judge from a move to an IDE with drag-and-drog functionality?
So, in short, I would appreciate any of your opinions on moving to a new JSF standard as well as your thoughts on IDE's.
Thanks.

If you don't want to sepnd much time and want to do something in the middle between JSF and JSP, you can use JSTL. Lots of cool JSTL components are available for free. Using struts (which is timetested) is also a good idea.
If you have never used any Java IDE, I would suggest you to use netbeans ide. Netbeans is really cool ide and has some good features like refactoring, jsp debugging etc. You will have to use Tomact as your server if you want to use JSP debugging effectively.
Eclipse with right plugin (My Eclipse) would be the best choice but you will have to understand some eclipse concepts before jumping on eclipse. It took me little time to figure out view, perpectives, plugins jargon.
Also My Eclipse is not free but it's very inexpensive - $30 per year.
All these are my experiances. I hope it helps you.
Vaibhav Puranik

Similar Messages

  • 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).

  • Comparing JSP and JSF, which 1 better?

    Currently i need to run a new project. Now i need to choosing 1 of the language to coding my project. Which 1 is better to use?
    In this project i have to include the web page that using JSP scriptlet to code because this project is create a dynamic menu to link up all web application. Is the JSF can link to JSP and JSP can link back to JSF?

    Welcome to SCN.
    Please read forum rules (you'll see that you must search the forum first (your question is already answered))

  • What's the difference between jsp and jsf?

    who can tell me what's the difference between jsp and jsf?
    I'm puzzled when I found some of the technology in jsp is so similar to the ones in jsp( javaserver page)

    Hi,
    Find the difference between JSP and JSF
    1. A developer has more control with JSP, but (should) get easier development with JSF
    2. Event handling is done differently in JSP (HTTP) and JSF (Java)
    3. The UI is designed differently (or should be at least) with JSP (markup) and JSF (components).
    4. The end product should also be defined differently - JSP page versus a JSF application.
    Is this the only thing that is need to make a decision for either or? Probably not. There are other pieces that need to be taken in account when deciding which technology to use - tools support, enough components, type of application etc.... At this point there are not enough JSF components (although there are some interesting projects underway - Ajaxfaces, Myfaces, ADF Faces, and WebChart 3d) and enterprise tools support is still limited to a few tools vendor. Looking at our ADF Faces components they are currently available as early access (not production) and demands for these components are stacking up, literally, outside my office doorstep. Although I would love to make them production - now! - it is not a viable solution since we are still checking features and fixing critical bugs.
    All this combined - not enough enterprise level components in production, lacking tools support etc... - leave customers in a vacuum where the decision is either to continue with JSP, since it is mature and has a wide developer base, or move forward with JSF not sure if the support, or the developers will be there. This is particularly sensitive to customers that need to get started now and be production by summer.
    If you are in this vacuum here are some key points promoting JSF:
    1. Fundamental unit is the Component
    2. Built in event and state management
    3. Component sets can be provided by any vendor
    4. Closer to ASP.Net or Swing development
    5. Choice of UI technology
    6. Scale up (rich clients)
    7. Scale down (mobile devices)
    8. Built into J2EE containers in J2EE 5.0 (tentative)

  • JSF 1.2 and JSP 2.1

    hi all
    i would like to know does JSP 2.1 apart for providing the Unified EL, also does away with the life cycle mixing of JSP and JSF as in previous combination such as jsf 1.1 and JSP .
    also would facelets be a better performer???
    Rajat

    It is tough to say if facelets would be a better performer or not a priori. You would probably have to instrument your application to discover this.
    JSPs are compiled into Java classes and so might run faster. OTOH, they likely have a heavier footprint (more memory used to load the classes and the interned strings).
    I don't know enough about facelets internals to know for certain, but suppose each facelet has a lighter footprint. Then you probably start with JSPs performing better with facelets catching up as you add more and more pages.
    But sometimes these things do not work out the may you might theorize. E.g., few people predicted that Java would be a performer on the server and that in fact the Java application performs better the longer it runs.
    Don't take anything I've said here as gospel, I am just speculating.

  • IDE developing JSP And Hebrew  Encoding

    Hi.
    I�m using Sun One Studio 4 CE.
    I�m new Java Programmer.
    I create JSP that use Taglib and read XML file written in Hebrew (Encoding iso-8859-1);
    When I run the file on a Tomcat I have no problems.
    But when I run the file within the ide of Sun One Studio I get gibberish.
    So. Do you know where I cane change the character settings so It work the same?
    Thanks
    Shimon

    The default encodings specified by the JSP and Servlet spec are unfortunately no good for most of the world!
    There are two issues you need to understand: page encoding, vs response encoding.
    Page encoding defines what encoding was used to create a particular page (JSP, XML, HTML). Unless the page encoding is set correctly, the entity that reads the page (e.g. the JSP parser, the web container, or the web server) cannot understand the characters before they do anything with them.
    Response encoding defines what encoding is used when the server sends the HTTP response to the browser. This is actually a separate issue from page encoding. For example, a JSP could have the page encoding set correctly (so that the JSP parser can read it), but if the response encoding is not set correctly, then what goes to the browser is still gibberish.
    To set the page encoding of a JSP, use a page directive:
    <%@page pageEncoding="UTF-8"%>
    (UTF-8 will work in Studio, there is no need to pick another more specialized charset).
    In a HTML file or XML file, use an XML directive to set the page encoding. The XML directive will not work in JSP though.
    So now the parser can translate the JSP into a servlet. But that's not good enough, because we also have to produce a response that the browser can understand.
    To set the response encoding from a servlet, you can use
    response.setContentType("text/html;UTF-8")
    In J2EE 1.4, you can also use response.setCharacterEncoding("UTF-8");
    To set it from a JSP, use
    <%@page contentType="text/html;UTF-8"%>
    All modern web browsers understand UTF-8, so that is a safe encoding to pick for the response. (It is a good encoding at the page level too if you use Studio. If you use another tool for your JSPs and it prefers a different encoding, use that at the page level but stick to UTF-8 for the response unless you have wireless clients and know that you need something else).
    Note that this can only be set before any of the response is written. So if this JSP is included into another one, and the response buffer size has been exceeded, it won't work. So the response encoding must be set as early as possible.
    What if you have a servlet that forwards to a JSP? Well, if you consider how the response object works, you should only have to set it once and earlier is better, so the servlet controller would be the obvious place. However, in J2EE 1.3, the encoding model wasn't well spec'd out, so on some servers, even if you set the response in the servlet, the JSP will overwrite it with the default if you didn't specify the content type. So experiment and set it in both the servlet and the JSP if you have to.
    From J2EE 1.4, it's OK to set the response encoding once, it the servlet - the JSP container doesn't overwrite it anymore.
    Check out the following link for more on i18n in web apps:
    http://java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/

  • Integration of JSP and xhtml in jsf project

    Can we use both jsp and xhtml in single jsf project. Actually I encountered a problem while configuring jsp and xhtml in web.xml of jsf project. The web.xml configuration file allows to use only one view handler (jsp or xhtml).By default it use jsp view handler. For xhtml view handler, we need to define following context param -:
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    Please let me know any possibility to configure both jsp and xhtml in jsf project(web.xml).
    My actual requirement is that I need to forward to new page(xhtml) from an xhtml page without using faces-config. I am not able to find any facelets tags which let me forward to new xhtml page. So I am thinking to use jsp to exploit the jsp tag called forward. But the constraint is that we can use only one view handler with jsf project.

    Can we use both jsp and xhtml in single jsf project. Actually I encountered a problem while configuring jsp and xhtml in web.xml of jsf project. The web.xml configuration file allows to use only one view handler (jsp or xhtml).By default it use jsp view handler. For xhtml view handler, we need to define following context param -:
    <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
    </context-param>
    Please let me know any possibility to configure both jsp and xhtml in jsf project(web.xml).
    My actual requirement is that I need to forward to new page(xhtml) from an xhtml page without using faces-config. I am not able to find any facelets tags which let me forward to new xhtml page. So I am thinking to use jsp to exploit the jsp tag called forward. But the constraint is that we can use only one view handler with jsf project.

  • Hi guys, problem with grey screen and flashing question mark. on top of it while in utility, i'm unable to verify, verify disc permission or repair disc0 which is obviously my main hd. any ideas where to go from here? tried to reistall osx but no luck.

    hi guys, problem with grey screen and flashing question mark. should be straight forward affair but on top of it while in disc utility, i'm unable to verify, verify disc permission, repair or even erase disc0 which is obviously my main hd. any ideas where to go from here? tried to reinstall osx but no luck, stucked when asked to chose location to install osx. would really apreciate any kind of help with this cause i'm quite new mac user. ty

    If you don't have a backup, read this:
    https://discussions.apple.com/docs/DOC-1689

  • Difference between JSP and JSF

    What is the difference between JSP and JSF?
    Is it necessary to learn JSP before starting with JSF?

    JSP is a view technology providing a template to write plain HTML/CSS/JS in. JSP supports Java based taglibs to generate output and/or control the page flow dynamically. A well known example is JSTL. JSP also supports access to backend data with help of EL (Expression Language).
    JSF is a component based MVC framework which provides taglibs for use in JSP, the JSF core tags in <f:xxx> and the JSF HTML tags in <h:xxx>. Those tags generate HTML output and are tied to JSF component tree in the server memory so that the FacesServlet can work on them to gather request parameters, validate/convert them, update the model values (javabean properties), invoke some actions (javabean action methods) and render the response.
    You can use JSF on top of either JSP or Facelets. Facelets is another view technology. JSP is ancient and has its shortcomings when JSF comes into picture. Facelets is designed with JSF in mind and much more well-suited for it and provides great templating/composition capabilities to reuse specific groups of components without the need to wrap them in another custom component (so that you don't duplicate the same code over and over, e.g. label+input+message.

  • Please recommend IDE for JSP and Beans

    Hi guys,
    I am looking for a decent IDE to work with JSP and Beans. I have tried JBuilder which has too much going on at the same time and I find it to be an overkill for what I am doing; I find NetBeans kind of irritating. I develop web applications, hence I dont need any GUI stuff for beans.
    Just looking for something that will enable me to rapidly develop beans as a support system for JSP pages and at the same time, it should provide good support for coding JSP pages. Little bit of management functions wont hurt either, but are not required. I dont mind if I have to pay for the IDE. Any recommendations?

    I like Eclipse for Java Development, and I use the MyEclipse plug-in for J2EE development.
    There is a free J2EE plug-in (Lomboz) but I'd much rather pay the $29.99/year for MyEclipse. It's been perfect for me.

  • Error while running JSF program in netbeans ide

    Hello guys,
    I was working with JSF on Netbeans 6.1 IDE. but was unable to run the application and got the following error :
    " javax.servlet.exception:PWC 1244: servlet execution threw an exception"
    "java.lang.NoSuchFieldError:IS_UNIT_TEST_MODE".
    However, this error ocurred only with JSF framework projects and not for JSP ones. So, the JSP files are built and run successfully.
    Please help me out with this.

    says it all really. You're trying to access something that doesn't exist, either explicitly or implicitly.
    Don't do that.

  • JSF, tiles, xml and xsl

    Good days people, I am employed at an app that wants to integrate JSF, tiles, xml and xsl.
    Basically the app receives information of the user's interfaz, builds an url with the above mentioned information and invokes to a service web that a xml returns with the information. The idea is to generate the exit in format html or wml with an insole(staff) xsl and to send the result in this format to every jsp that is going to form a part of the page that it will generate tiles. at first I understand that it is feasible, i�d like to know if someone already has done it and since it has done it.
    Just now what I have is a managed bean that receives the parameters of the altar frontal and invokes a method of a service, like this:
    public String encuentra(){
    //deja los atributos privados rellenos.
    String mensaje ;
    crearYRellenarBusquedaVO();
    try {
    setResultado(this.getServicio().obtenerResultadosWML(this.getBusquedaVO()));
    mensaje="succesNoJS";
    }catch(java.lang.IllegalArgumentException e){
    mensaje="error";
    }catch(es.yell.frontlite.exceptions.SrvBusquedaNoxtrumServiceException e1){
    mensaje="error";
    }catch(Exception e2){
    mensaje="error";
    return mensaje;
    public String obtenerResultadosWML(es.yell.frontlite.service.impl.BusquedaVO busquedaVO){
    if (busquedaVO == null){
    throw new IllegalArgumentException(
    "obtenerResultadosJSdesactivado(es.yell.frontlite.service.impl.BusquedaVO busquedaVO) - 'busquedaVO' no puede ser nulo.");
    try{
    return this.manejarObtenerResultadosWML(busquedaVO);
    }catch(es.yell.frontlite.exceptions.SrvBusquedaNoxtrumServiceException e1){
    throw new es.yell.frontlite.exceptions.SrvBusquedaNoxtrumServiceException(
    "Error ejecutando el servicio String obtenerResultadosJSdesactivado(es.yell.frontlite.service.impl.BusquedaVO busquedaVO). " + e1.getCause(),e1);
    }catch(Exception e){
    throw new es.yell.frontlite.exceptions.SrvBusquedaNoxtrumServiceException(
    "Error ejecutando el servicio String obtenerResultadosJSdesactivado(es.yell.frontlite.service.impl.BusquedaVO busquedaVO). " + e.getCause(),e);
    //it returns html code!
    protected String manejarObtenerResultadosWML(es.yell.frontlite.service.impl.BusquedaVO busquedaVO)
    throws java.lang.Exception{
    try{
    // xmlOrigen has full xml response from server
    String xmlOrigen = manejarObtenerResultadosJSActivado(busquedaVO);
    Source xmlSource = new StreamSource(new StringBufferInputStream(xmlOrigen));
    Source xsltSource = new StreamSource(SrvBusquedaNoxtrumServiceImpl.class.getResourceAsStream(Constantes.XSL_FILE));
    StringWriter cadenaSalida = new StringWriter();
    Result bufferResultado = new StreamResult(cadenaSalida);
    TransformerFactory factoriaTrans = TransformerFactory.newInstance();
    Transformer transformador = factoriaTrans.newTransformer(xsltSource);
    transformador.transform(xmlSource, bufferResultado);
    System.out.println(cadenaSalida.toString());
    return cadenaSalida.toString();
    }catch(Exception e2){
    throw new es.yell.frontlite.exceptions.SrvBusquedaNoxtrumServiceException (e2.getMessage());
    With this exit in html, since(as,like) how could i forward it towards a jsp especially?
    faces-config.xml
    <navigation-rule>
    <from-view-id>/index.jsp</from-view-id>
    <navigation-case>
    <from-outcome>succesNoJS</from-outcome>
    <to-view-id>/jsDesactivado.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
    <from-outcome>error</from-outcome>
    <to-view-id>/error.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    index.jsp
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <f:view>
    <f:loadBundle basename="MessageResources" var="msg"/>
    <head>
    <title>
    ${msg.titulo}
    </title>
    </head>
    <body>
    <h:form id="formulario">
    Que:
    <h:inputText id="campoQue" value="#{yellProxy.campoQue}" />
    Donde
    <h:inputText id="campoDonde" value="#{ yellProxy.campoDonde}" />
    <h:commandButton id="boton" value="Encuentra" action="#{yellProxy.encuentra}"/>
    </h:form>
    </f:view>
    </body>
    </html>
    jsDesactivado.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri=" http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    " http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
    </head>
    <body>
    <h1>JSP Page</h1>
    jsDesactivado!!
    <%--
    This example uses JSTL, uncomment the taglib directive above.
    To test, display the page like this: index.jsp?sayHello=true&name=Murphy
    --%>
    <%--
    <c:if test="${param.sayHello}">
    <!-- Let's welcome the user ${param.name} -->
    Hello ${param.name}!
    </c:if>
    --%>
    <jsp:getProperty name="yellProxy" property="resultado"/>
    </body>
    </html>
    If you could pass me a simple example of use of an app that uses JSF, tiles, xml and xsl, i�be grateful
    regards a lot!

    We too (at Viking Freight) would also be very interested to see if anybody
    has produced such a useful series of classes...
    Frank Lees, Developer
    -----Original Message-----
    From: Amin, Kamran [mailto:kamran.aminframeworkinc.com]
    Sent: Wednesday, January 19, 2000 12:11 PM
    To: 'Forte User'
    Subject: (forte-users) XML and XSL in Forte
    Has anybody integrated an XSL parser with Forte. I know Forte provides us
    with an XML parser but that does not help with parsing XSL. There a lot of
    parsers written in JAVA but that will not integrate well with Forte. We
    need something that will be easy to integrate with Forte. This parser will
    take our XML and XSL to give us a result set. If anybody can comment on the
    subject or share some information I would appreciate it.
    thanks in advance.
    ka
    For the archives, go to: http://lists.sageit.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.sageit.com

  • Retrieving lists from other layer into a JSP page - Design Question

    Hi all,
    What should be a good design technique in order to allow a JSP page to present some list obtained from other layer of my application. I intend to leave only presentation logic in the JSP layer, while all data access will be in other layer.
    For example, I have a JSP page that will show the results of a SQL query originated from an entry form in other JSP page. Let's name them 'search.jsp' and 'result.jsp'
    I want that all JDBC access be done in some other layer.
    Question 1:
    What would be better for this task? A servlet or a bean? (A bean, I suppose?)
    Then this bean (?) would have to find some way to pass all the result set into this 'result.jsp'. I think it would be very poor design if I used some Data Object, because it would have to store all rows and pass them at once.
    I don't want, either, that the presentation (JSP) layer access directly the data access layer (JDBC, files...). This way, I don't want any JSP page accessing the Resultset object directly.
    Question 2:
    What do you think could be a good design technique?
    I thought of some intermediate layer that provided data objects and data access interfaces. I mean, as my data will come from different sources, like some database (JDBC), some Electronic Document Manager, I thought of having a common access interface, that would provide methods for accessing the resultsets. This could be even a java.util.Enumeration that has a hasMoreElements() method that could be implemented as the next() method from JDBC result sets and the nextElement() method that would actually bring the next row of data.
    This way the JSP layer would see only hasMoreElements() and nextElement() methods from the middle layer. On the other hand, the data layer would provide as many different implementations to this access interface (Enumeration?) as there were data sources (JDBC, Files, ...)
    Question 3:
    What do you think of this design?
    Question 4:
    Is there any flaw in my approach? Which?
    Question 5:
    Could you suggest other designs?
    I really thank you all, for any kind of answer. I actually use this design for development, however I've never seriously discussed it with someone... this is going to be of great value for me.
    Regards,
    Filipe Fedalto

    Well I saw you question and I'll tell you what I do.
    I have JSP's which post form data to servlets.
    The servlet then calls a factory to produce a ResultContainer (analagous to your lists) which is generated
    via JDBC, and/or request parameters etc...
    this provides a single point of reference and a "group" of containers (functions really) that can be produced and reused (same container different amount of data)
    I also have other static classes which can manipulate the data in the containers
    (such as add additional info to the items in the containers) before I forward the container (request attribute)
    to the JSP page
    Additionally I use Type safe constants for all my HTML form tag names (easier to change and ensure the same name is used everywhere when reading parameters) and again for item statuses
    and any other info I need to send along with the page (using Javascript to update the
    status to another type safe constant).
    I've found that using factories for ResultContainers is very worthwhile and allows you to implement additional servlets extremely quickly (mostly reusing containers that exist) and since the
    container is the same for all my JSPs (this may not be the case with you) I can implement JSP's
    very quickly as well (just change the view)
    btw I refrain from calling my ResultContainer a bean because it is not serializable
    I don't know if this will help but at least it gives me a forum to test my ideas
    Thanks

  • Sun IDE Question

    I've posted the question in the Sun ONE Studio forum, but no answer there, so I'm trying here, in the hope that I can get some assistance. This is not really about Java, but about using the Sun ONE Studio IDE.
    I go through the tutorial building a jsp page and come to the point where I execute it. The compile runs clean, the embedded Tomcat server starts, the browser opens, and displays HTTP 404 error, unable to find the requested JSP file. The URL in the browser address is http://localhost:8081/WEB-INF/ProductList.jsp, and the file is present at that location. Entering in just http://localhost:8081 does bring up the index.html page I stuck in the home directory of my application.
    I've verified that the Tomcat server is the default server (I don't have any others installed on my system), and for grins, uninstalled and reinstalled both the IDE and the Java SDK, with no change in the results.
    I guess I'm getting frustrated. I'm sure it is something easy, some setup configuration that is not set, but I'm not having any luck, nor can I afford to pay the $200 support request to get an answer from Sun.
    Log file for tomcat shows this:
    2002-06-27 18:06:26 StandardHost[localhost]: Installing web application at context path /webdav from URL file:C:\ide-userdir\tomcat401_base\webapps\webdav
    2002-06-27 18:06:26 WebappLoader[webdav]: Deploying class repositories to work directory C:\ide-userdir\tomcat401_base\work\localhost\webdav
    2002-06-27 18:06:26 StandardManager[webdav]: Seeding random number generator class java.security.SecureRandom
    2002-06-27 18:06:26 StandardManager[webdav]: Seeding of random number generator has been completed
    2002-06-27 18:06:26 ContextConfig[webdav]: Added certificates -> request attribute Valve
    2002-06-27 18:06:26 StandardWrapper[webdav:default]: Loading container servlet default
    2002-06-27 18:06:26 default: init
    2002-06-27 18:06:26 jsp: init
    Nothing looks like it broke, at least until I try to load that darned page, then the HTTP 404 not found error :(.
    Any help would be appreciated, thanks.

    Try moving ProductList.jsp to the same directory as index.html.
    A better way is to assign a context root to the web app.
    In the Forte Explorer window, click on the project tab. Right click on the WEB-INF directory and select Properties. There should be a context root for the app. If not, enter one. e.g. "/myapp"
    Place your JSPs directly in the document root (this is directory above WEB-INF).
    Now try to view your JSP. The URL should be http://localhost:8081/myapp/ProductList.jsp

  • MVC JSP and Servlets

    I'm creating JSP pages to represent the view of the site and servlets to get the request and decide which JSP page to load next.
    When the servlet recibes a request it generally has to query the database to get some data and then show it back to the client. To do this the servlet calls other object that is responsible to query the database and fill a ResultSet.
    My question is: what is better, to load a Vector with special objects containing the data in the ResultSet and then return this vector to the jsp page for it to use it, or may a return directly the ResultSet to the jsp page? With the first option I have to cycle in the resultSet to load the vector and then cycle through the vector to show the results. With the second option I cycle only once, but I isolate from the database (column names, order in which the things are returned...)
    I hope anybody can give me an opinion.
    Thanks

    There are a few things wrong with this:
    1) MVC -> The View should have no Model work init.
    For the MVC pattern, the database is Model. Use
    a
    a ResultSet in JSP, and now your View is lockedto
    a
    database with a specific column format.
    Huh? I think that's backwards. The View willalmost
    always require Model data unless it is a staticpage.
    The Model, however, should be agnostic about what
    t View technology it serves. (The Controllerbridges
    the two). Also, I would call the database the
    Persistence or Integration tier, a separateconcept
    from the Model, though intimately coupled to it.I meant the work of the model (gathering the data to
    a presentable form) is moved to the View. Yes, the
    View needs to know the Model to be able to display
    its data. But the Model should handle the data
    collection.
    Fair enough. I might have read it backwards as well.
    >>
    2) Any web application (or any application in
    general) wether it uses MVC or not, should still
    follow a 3 tier approach: Persistance (Data),Domain
    (logic), Presentation (View, output) (note, thisis
    different then MVC.) By moving the ResultSet inthe
    JSP you would be dragging the Persistancemechanism
    up two layers. Generally, a layer should only
    see
    the layer just below it (Presentation seesDomain.
    Domain sees Persistance. Persistance never sees
    s Domain or Presentation. Domain never sees
    Presentation. Presentation never seesPersistance).
    >
    I agree that Persistence and View should not seeeach
    other. However, Model and Persistence must. How
    else do you write a DAO? Or even use a mapperlike
    Hibernate?First the Model doesn't fit into just one of the
    three tiers (Persistance Domain and Presentation).
    The Model of MVC is both the Domain logic and the
    e Persistance mechanism.
    To me, at least, Domain logic = model. The terms I have normally read is either "business tier" or "model domain". "Patterns of Enterprise Application Architecture", M. Fowler. Though, I will concede that this tier has the least well defined set of terms.
    But for the three tier architecture: the domain sees
    the persistance. You always see one layer down. So
    Domain sees the persistance and pulls the data into
    the model. So a DAO would be part of the Domain, the
    logic of collecting the data from the database to be
    used in the application (in the correct object graph
    and all that). The persistance though, doesn't see
    the domain.
    Hmm, I'm not sure which direction 'down' is. And even if 'down' meant towards the back-end or away from it, what about the controller? It parses view requests and delegates them to the model. The results are then normally returned to the controller for dispatch to a view. So, the controller seems to have its fingers in all the tiers except integration and persistence, at least to me. I think of the controller as the 'middle man' between model and view that lets the model be agnostic to the view. The view and controller will to some extent always be coupled. However, the model theoretically exists on its own.
    Half of me thinks that I have a different view on
    where the Domain and Persistance border is. I
    thought the DAO or the Data Mapper would be in the
    Domain, whereas you seem to be saying they are in the
    Persistance layer?
    That's interesting. I don't know if there is an absolute answer. We are dealing with the O/R boundary, and the DAO straddles the boundary. However, one could, at least theoretically, change persistence strategies. What would change? Not your model objects, but your persistence tier objects. Though, again, the definition is nebulous.
    3) From a Practical matter:
    In many DBs, if you close the connection fromwhich
    the ResultSet was derived, the ResultSet is
    closed
    and you get errors if you try to access it. Ifyou
    don't close the connection in the Servlet beforeyour
    JSP, then you have to do it in the JSP. Thatmeans
    even more DB bleed through to the JSP, and theM->V.
    Or, you could just not close the Connection and
    d allow it to hang around and create memory
    leaks.
    >
    Yepper.
    4) Also practical:
    To use the ResultSet in JSP is going to require
    scriptlet code. This is ugly and hard to manageand
    update later. You have to wrap your code in
    try{}catch(SQLException e) {} finally {}, so
    the
    code is even uglier and harder to manage(especially
    if you end up not touching the thing for monthsand
    forget what you had done - or god forbid someoneelse
    has to keep up your code). You could make acustom
    tag to handle it, which makes the JSP easier toread,
    but does further damage of spreading the dataaccess
    code all over the application.
    Definitely!
    5) Practical:
    When you do this sort of thing, then later
    decide
    to
    change the way the database is set up, digging
    all
    the places affected by the simple renaming of a
    column, or refactoring of which columns are inwhich
    tables becomes a heavy effort. Keep it all in a
    DataAccessObject, and changes in DB becomestrivial
    to keep track of in your code. It is all in one
    place, and can be tested off line. Harder stillis
    if you change persistance from a database to anXML
    library, or some directory lookup or something.You
    would have to completely refactor your Servlet
    and
    your JSP. Put it in a DataAccessObject and allyou
    have to do is switch out the DAO instance. The
    change is transparent to the Servlet and the JSPas
    long as you maintain an interface.
    Just keep in mind that for the vast majority of
    projects, the RDBMS technology is rarely switched.I
    generally program to interfaces in my Model, butmy
    Persistence tier is always so tightly coupled thatI
    simply use POJO's without an interface.
    6) Practical:
    I have elluded to this several times, but I will
    state it specifically. When you isolate the
    persistance and data access to its own layer
    then
    you
    can swap out the presentation (the View and the
    Controller) when testing all your persistance
    operations. This means the data is independent
    of
    the container. You can run it out of theServlet/JSP
    environment and it will behave EXACTLY as it
    will
    inside the JSP environment. You can designrobust
    tests, debug, redesign, re-edit, etc... muchquicker.
    Then, when all done, plug it into your web app
    p without worry.
    Great point.
    Of course, Numbers 3 -> 6 are the reasons why
    following 1->2 (MVC and the 3 Tier architecture)are
    such good ideas.- Saish
    BTW, please take all the above just in the interest of having a good discussion. I have been wrong many times before! ;^)
    - Saish

Maybe you are looking for