Why do we use both servlets & jsps in developing  an application ?

why do we use both servlets & jsps in developing an application & not only jsps

Hi,
It's a pure question of design : Some like it jsp to jsp and others servlet to jsp. It's up to you to decide and it depends of the complexity of your application.
But the best design is the MVC (servlet and jsp working together) because it helps you separate presentation from logic. It also helps you better maintain you code.
You can have more info in javaworld.com.
Good luck
touco

Similar Messages

  • Why all classes in javax.servlet.jsp are abstract?

    Hi all,
    I have two questions about how the package was designed:
    1.) why all the classes in the javax.servlet.jsp are abstract? what is the benefits?
    2.) why almost all the methods in the class, such as jspWriter, are abstract too? And we can use these abstract methods in the way we use "concrete" methods?
    3.) the same thing for HTTPServlet class at javax.servlet package.
    Thanks in advance
    yllx

    Thanks for the message. In fact, you don't need to reply to the message if you don't have the answer.
    I suspect that this has something to do with the abstract factor design pattern. It allows each container engine to implement the detail based on its own specification. I just need some body to put more details on that.
    Since this happens quite often if the J2EE library, it's good for us to understand why they do this way, and how we can use it in our design.
    yylx

  • Why does TestStand use both comma and period for decimal point separation?

    TestStand stores our test data to a SQL server using SQL Server Stored Proc, but for some reason a comma is used for separation (double values) for "PROP_NUMERICLIMIT.HighLimit" and "PROP_NUMERICLIMIT.LowLimt", but not for "PROP_RESULT.Data" (or any other numeric value field). Why is that? I haven't been able to figure out if it is a bug or if I have missed some step in the configuration.

    I ran across this in the TestStand Help. You might want to try the change in the ODBC Administrator.
    When you use the MySQL ODBC driver and the operating computer specifies a comma character as the decimal symbol character, the ODBC driver might return an error because the ODBC driver internally converts a floating-point value to a string value. The computer locale causes MySQL to interpret the comma decimal symbol character in the SQL syntax as a multi-value list character separator. Configure the MySQL data source in the ODBC Administrator and enable the Don't Use Set Locale option in the Miscellaneous Options section to resolve this error.

  • How to display RTF File in Browser Using Servlets/JSPs

    Hi All,
    I have some RTF Files, which contains some data.
    The data needs to be displayed in the frame of jsp page .
    How i can display the RTF File Content using either servlets/jsps
    Can any body have idea on this.
    Help me out on this.
    With Regards
    Hari

    If you only need to display it, consider your HttpServletRequest just as byte stream. :) Just read from ServletInputStream and write it back into ServletOutputStream of HttpServletResponse.
    If you want to process incoming XML, please give some details first, what exactly you want to do. :)

  • Where should the support classes of servlets, JSPs and EJBs be placed

              Hi
              Could you please tell me where the support classes (simple
              java classes) used by servlets, JSPs and EJBs should be placed.
              I find that my application does not work if I place all the
              support classes of a servlet under $MYSERVER/clientclasses. I need to place some in $MYSERVER/clientclasses and some in
              $MYSERVER/servletclasses. But I figured this out my trial and error and I could not find any logical explanation why some of them should go into $MYSERVER/clientclasses and others into
              $MYSERVER/servletclasses.
              Thanks
              Regards
              Pratima
              

    you can put 'em in weblogic classpath
              Kumar
              Pratima Nambiar wrote:
              > Hi
              > Could you please tell me where the support classes (simple
              > java classes) used by servlets, JSPs and EJBs should be placed.
              > I find that my application does not work if I place all the
              > support classes of a servlet under $MYSERVER/clientclasses. I need to place some in $MYSERVER/clientclasses and some in
              > $MYSERVER/servletclasses. But I figured this out my trial and error and I could not find any logical explanation why some of them should go into $MYSERVER/clientclasses and others into
              > $MYSERVER/servletclasses.
              >
              > Thanks
              > Regards
              > Pratima
              

  • Cannot use QuickTime functions in a plain C++ application

    Hi,
    Im new to QuickTime.Now i need to use quicktime7.1 SDK functionalities in my plain C++ application.Hence I started with a plain C++ application just to check whether i can access the quick time functions there.Im currently using Dev-cpp IDE for developing my application.
    Given the sample code.
    #include<iostream>
    #include<conio.h>
    #include<QuickTime.h>
    using namespace std;
    main()
    int ver=0;
    ver=quicktime_major(void);
    cout<<"VERSION"<<ver;
    getch();
    The given program uses the quicktime function quicktime__major to get the version information.The function returns an integer value,which is the version of the quicktime installed.The function is declared with in the header quicktime.h.Hence i added the header file.
    On Compiling,I am getting some errors in the main function as listed :-
    main.cpp: In function `int main()':
    main.cpp:9: error: expected primary-expression before "void"
    main.cpp:9: error: `quicktime_major' undeclared (first use this function)
    main.cpp:9: error: (Each undeclared identifier is reported only once for each function it appears in.)make.exe: * [main.o]
    Error 1Execution terminated
    I am getting so many other errors in the quicktime header files which i am not able to get resolved.Some sample errors are listed below.
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: conflicting declaration 'kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: 'kATSULineWidthTag' has a previous declaration as
    `<anonymous enum> kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: declaration of `kATSULineWidthTag'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:145: error: conflicts with previous declaration `<anonymous enum>
    kATSULineWidthTag'
    [this same error is repeating for all the enum members in the header file ATSUnicode.h ]
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticLineUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, void*)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2523: error: redefinition of `OSStatus (*
    NewATSQuadraticLineUPP(OSStatus (*)(const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const
    Float32Point*, void*)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2523: error: `OSStatus (* NewATSQuadraticLineUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, void*)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticCurveUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, const
    Float32Point*, void*)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2542: error: redefinition of `OSStatus (*
    NewATSQuadraticCurveUPP(OSStatus (*)(const Float32Point*, const Float32Point*, const Float32Point*, void*)))(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2542: error: `OSStatus (* NewATSQuadraticCurveUPP(OSStatus (*)(const
    Float32Point*, const Float32Point*, const Float32Point*, void*)))(const Float32Point*, const Float32Point*, const
    Float32Point*, void*)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2561: error: redefinition of `OSStatus (*
    NewATSQuadraticNewPathUPP(OSStatus ()(void*)))(void)'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2561: error: `OSStatus (* NewATSQuadraticNewPathUPP(OSStatus
    ()(void*)))(void)' previously defined here
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: At global scope:C:/Program Files/QuickTime
    SDK/CIncludes/ATSUnicode.h:2578: error: conflicting declaration 'uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: 'uppATSQuadraticClosePathProcInfo' has a previous
    declaration as `<anonymous enum> uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: declaration of `uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2578: error: conflicts with previous declaration `<anonymous enum>
    uppATSQuadraticClosePathProcInfo'
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h: In function `OSStatus (* NewATSQuadraticClosePathUPP(OSStatus
    ()(void*)))(void)':
    C:/Program Files/QuickTime SDK/CIncludes/ATSUnicode.h:2580: error: redefinition of `OSStatus (*
    NewATSQuadraticClosePathUPP(OSStatus ()(void*)))(void)'
    Can anyone help me to resolve the above issues?
    Thanks in advance,
    Sans

    Antoine;
    There is a good KnowledgeBase at NI home page talking about that issue.
    If you go to www.ni.com and type +ni-daq +run +borland at the search engine of the page, the second result is the link to the KB I'm referring to.
    Hope this helps.
    Filipe

  • Why we are using servlet as a controller instead of Jsp?

    Can any explain answer for this question
    Thanks in Advance
    Why we are using servlet as a controller instead of Jsp?

    nareshannam wrote:
    Can any explain answer for this question
    Thanks in Advance
    Why we are using servlet as a controller instead of Jsp?Basically JSPs are suited to do just one thing, to generate HTML with variable content. You can put Java code in there too, but it's not a good place for it. Messy to validate, messy to debug. In fact, with tag libraries like JSTL, actual Java code is rare in professionally written JSPs.
    A controller does the bit that comes before you've decided what kind of response the user is going to get, typically it may invoke one of several JSPs according to validation etc.. There's a lot of logic, a lot of parsing parameters and so on. Much cleaner to do this from a Java class like a Servlet.
    Judging by this forum quite a lot of people come to JSPs from ASP or PHP and don't want to bother with actually writing Java classes. That's never going to be much good.

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • Why do we use jsp instead of servlet

    why do we use jsp instead of servlet

    Hi,
    I am and web/Java developer and have used a mixture of JSPs and servlets. I use JSPs for my actual web pages. Whether they are displaying dynamic database driven content or simple pages doing nothing but password protecting.
    I tend to separate other reusable code into servlets, like database connections and business logic.
    For example: I have worked on a mortgage site and there quite a lot that goes into calculating a monthly payment and ARP. These calculations will not change (only values I send to them will) therefore I do this type of coding in a servlet.
    Cheers
    Mark
    :o)

  • Why we should use JSP instead of Servlet ?

    I want to know what are the advantages to use JSP over Servlet.

    hi
    Servlets are server exctension ( like CGI ) separate executable
    modules to serve any request efficiently.
    Servlets are pure java classes, u can use them the write an html code to browser.
    u have to compile the servlet before u use it.
    JSP page, is a text-base document , u can type html inside it , and u can use java as scripting language, so it is more easy to use jsp rather than servlet as each jsp page is translated into a servlet by JSP engine.
    Hope this will help
    Good luck
    Mohammed

  • How to track the same session using both jsp and servlets

    Hello, guys:
    "how to use jsp and servlet to track the same session",
    it seems to me my logoff.jsp never realize the session I established in my servlets.
    Here is how I set my session in my servlets:
    "     HttpSession session = req.getSession(true);
    session.setAttribute("userid",suserid);"
    Here is how I invalidate my session in my logoff.jsp
    " <%@ page language= "java" %>
    <%@ page import="javax.servlet.http.HttpSession" %>
    <%@ page session="false"%>
    Our Session id is : <%= session.getId() %>
    <% session.removeAttribute("userid");
    session.invalidate();
    %>
    Our Session id is : <%= session.getId() %>"
    but when I try to logoff using the logoff.jsp
    I always get following error message.
    "/home/jiao/jsp_webserver/tomcat/work/Standalone/localhost/syllabus/htmls/logoff_jsp.java:50: cannot resolve symbol
    symbol : variable session
    location: class org.apache.jsp.logoff_jsp
    out.print( session.getId() );"
    T.I.A.
    [Edited by: jiveadmin on Jun 18, 2003 10:32 AM]
    [Edited by: jiveadmin on Jun 18, 2003 10:33 AM]

    So,
    <%@ page session="false"%>
    That means the jsp never instantiates the build in session object.
    <%@ page session="true"%>
    means jsp will instantiates a session object if there are no existing ones
    how about I just delete the line,
    does that mean the jsp will find the existing session object for me?
    So I can do something like
    Our Session id is : <%= session.getId() %>
    <% session.removeAttribute("userid");
    session.invalidate();
    %>
    directly.
    T.I.A.

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

  • When to Use Servlet only, EJB only and, both Servlet And EJB???

    I have a question, If I want to build a Web application. Sometime i found that there is no need to use EJB as Servlet already provide that functionality.
    Can anyone tell me when do I use Pure Servlet? When do I use Pure EJB and, When do I use Both EJB and Servlet???
    I am very interesting in it.
    Thanks.
    Jack

    EJB and servlets are two different things. Trying to compare them doesn't really make sense. A web application is always going to need some way to process Http requests and this in Java is done accomplished through Servlets (or jsp pages which in turn also use servlets).
    EJBs are the basis of distributed cross-platform objects. They are handled through name services and stored in databases. An Entity Bean can be "brought back to life" as long as it's info is stored in a database. Regardless of a server being restarted. All this database support behind an Entity Bean (transactions, queries etc.) are very transparent to the programmer. They are provided by the EJB vendor.
    The class properties of a Servlet (or class-level member variables) are shared among all requests (running thread instances of the service method). That's why they should be used with a lot of caution. This feature can be very useful but if used improperly can also be very vulnerable to security and synchronization issues.
    I'm not an EJB expert but this explanation should give you some idea of what EJBs are all about.

  • Need a good charting library (for use in a servlet/jsp environment)

    Anyone know of a good charting library for use in a servlet/jsp environment.

    Use JFreechart combined with cewolf.
    www.object-refinery.com/jfreechart/
    To use charts in a jsp page you can use cewolf ( a taglib) based on jfreechart.
    http://cewolf.sourceforge.net/
    Both are free.

  • Why do we use jap instead of servlet

    why do we use jap instead of servlet

    JSPs are compiled into servlets. Use them to more conveniently generate presentation code such as HTML. With a JSP, you can code the HTML directly, no need for lots of "out.println" statements. JSPs can be written by non-programmers who don't know Java using the built-in JSP features plus custom tags libraries.

Maybe you are looking for

  • Project Server 2010: PWA Removing Default Project Site Security Groups When Creating a New Project

    I looked for this specific issue with Project Server 2010/PWA/SharePoint and could not find an exact answer... hopefully someone can help. We are currently using Project Server 2010 and have a number of project site templates that are used dependent

  • I-pod shuffle 1 will not show up in i-tunes or my computer - HELP!!!

    I have the first version of the i-pod shuffle and was using version 9 of i-tunes without any problem until the computer died - the hard drive had to be replaced. I have reloaded the software for the i-pod and i-tunes but when I connect the i-pod it d

  • Make WebDynpro Appliction available on Internet

    Hi Experts, We have to develop a POC for our client. We need to build a small application and make it available to be accessed on internet. We have already developed a view and have created an application. When I click test, the view opens in a webpa

  • Length report double

    Hi, I have the code below and i am not sure why the length of the attribute are reported double Code: FIELD-SYMBOLS:     <fs_comp_wa> TYPE abap_compdescr. DATA: lr_desc_table    type ref to CL_ABAP_TYPEDESCR,         lr_desc_struc    type ref to cl_a

  • Code from 1 VI split up in different VI's

    I'm developping a somewhat bigger project. Until now all my code is in one VI... Is it possible to split up my code from 1 VI in different VI's. Now I have the import of textfiles, the communication with a device (gpib), the read from gpib, the calcu