Difference between jsp and servlets

Can any body tell me the difference b/w jsp and servlets.
As i know one difference is to seperate the java code from html. Is there any other difference. please...

Servlets are a way to run java on a server. They don't necessarily need to be about HTML or even HTTP. You can write servlets that generate images rather than HTML, for example.
JSP is a way to create servlets that generate HTML. They get translated into servlets (special-purpose servlets). This is sort of glossing over the details -- the power of JSP is that, by being an intersection between HTML and executed Java code, they can provide a way to clearly differentiate between the two.
That's a way of looking at it anyway.

Similar Messages

  • What is the diff between jsp and servlet

    is thr any other difference betwwen jsp and servlet, tht: jsp is automatic generated servlet and jsp has different types of tag, due this we have write less amount of code.any other technically difference between these two?

    As you mentioned JSP automatically gets converted into a Servlet and then compiled. From the server's perspective other than the transformation process, there is no real difference.
    However, in coding there are some minor differences such as additional access to pre-defined variables and different syntax for some minor things such as imports and etc.
    Perhaps somebody else more knowledgeable can fill you in further.
    Hope that was helpful.

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

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

  • Passing session data between jsp and servlet

    I have a servlet that I pass data to my jsp.
    I do a session.setAtrribute in the servlet. No problem.
    I get the data no problem in the jsp that I call.
    How do I pass this same data to the another servlet?
    I basically have an array of values that I already have in the existing jsp that has been set in session.
    When I call the secondary servlet, I don't have anything in this session variable related to my array.
    Prior to posting to my next servlet, do I need to do another setAttribute inside the jsp to get the data passed to the servlet?
    Thanks.

    Two different things. The encoding adds this to the URL (after the page, before the query string
    ;jsessionid=ABC123 but only if the user isn't using cookies.
    So in your example, you would do this (maybe):
    <%
      String url = response.encodeURL("Servlet");
    %>
      <form name="form1" method="post" action="<%= url %>?cmd=pay"> ... Or some modification.
    So the difference between encodeing and using a post is that
    1) encoding adds the jsessionid to the url string if necessary. It does nothing else
    2) POSTing will send a request to the provided URL via the POST method, including the inputs of the form as parameters to the URL.
    They really don't interact with each other. It is like asking what is the difference between the Color Orange and thr Size Big? They can both be applied to the same thing, or not... and have no real relation to each other.

  • Whats the difference between *.jsp and *.jspx

    Hi
    When I create a new jsf page the first step prompts me for the "type". I am wondering what is the difference between JSP Page and JSP Document? Which should I be using? Are there any white papers or documents that explain the advantages of each?
    Also, someone suggested that I use Facelets, has anyone else used these from inside jdeveloper? Any thoughts / tips would be appreciated.
    Thanks
    troy

    JSPX uses an XML doument for you page code - it is the way we recommend you build your page. Makes for cleaner code and easier customization.
    JSP uses HTML with embedded JSF tags in it.

  • Difference between JSP and ASP

    Whatz the diff between JSP and ASP

    Hello msdnexpert,
    Active Server Pages (ASP) allows you to build rich, data driven, dynamic complex applications. ASPs are written in Perl, VBScript, C/C++. They run on machines running Microsoft Windows. With ASP, an HTML page on a web server can contain snippets of embedded code. This code is read and executed by the web server before it sends the page to the client (usually a browser such as Netscape Navigator or Microsoft's Internet Explorer.) For more information on ASP see:
    http://www.microsoft.com/workshop/server/default.asp
    or
    http://www.activeserverpages.com
    Java Server Pages (JSP) also allows you to build rich, data driven, dynamic complex applications. JSPs are written in Java. They run on any Java enabled machine, including Solarlis, Windows, Linux, and Mac OS. JSPs also makes available all of Java's industrial strength security for free. JSPs uses a syntax similar to ASP except that the scripting language is Java. Unlike ASP, JSP is an open standard implemented dozen of venders across all platforms. JSPs are closely tied to servlets because a JSP page is transformed into a servlet as part of its execution. For more information on JSP see:
    http://java.sun.com/products/jsp
    A servlet is a generic server extension -- a Java class that can be loaded dynamically to extend the functionality of a server. Servelets are commonly used with web servers, where they can take the place of CGI scripts. A servlet is similar to a proprietary server extension, except that it runs inside a Java Virtual Machine on the server side, so it is safe and portable. Servlets operate solely within the domain of the server: Unlike Applets, they do not require support for Java in the web browser.
    Unlike CGI, which must use multiple process to handle separate programs and/or separate requests, servlets can all be handled by separate threads within the same process or by threads within multiple processes spread across a number of back end servers. This means that servlets are also efficient and scalable. Because servlets run with bi-directional communication to the web server, they can interact very closely with the server to do things that are not possible with CGI. Another advantage of servlets is that they are portable: Both across operating systems and across web servers.
    Resources used in researching this response:
    Java Servlet Programing 2nd Ed by Jason Hunter with William Crawford.
    http://press.oreilly.com/jservlet2.html
    http://oreilly.com/catalog/jservlet2/
    -Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • Urgent: problem with sharing HttpSession  object between Jsp and servlets.

    Hi,
              We are using weblogic 6.0 sp2.
              I m setting a particular object in session in a servlet using
              session.setAttribute() but when i try to retrieve that object using
              session.getAttribute() in a jsp page the value of that object is null. Is
              there any way to configure HttpSession in weblogic so that jsps and servlet
              can share the same session? Or any workaround for this problem.
              Any help in this regard is appreciated.
              Thanks
              -Shree
              

    Just a guess, but it sounds like you have cookies turned off and are not
              using encodeURL. Try enabling cookies and see if that solves the problem.
              Also, it is generally good practice to use encodeURL to protect yourself
              from users who disable session cookies.
              Here's how we use encodeURL in our Servlets:
              gotoPage("/jsp/someJSP.jsp");
              private void gotoPage( String address,
              HttpServletRequest request,
              HttpServletResponse response )
              throws ServletException, IOException
              RequestDispatcher dispatcher =
              etServletContext().getRequestDispatcher( response.encodeURL( address ));
              dispatcher.forward( request, response );
              "Shree Unde" <[email protected]> wrote in message
              news:[email protected]..
              > Hi,
              > We are using weblogic 6.0 sp2.
              > I m setting a particular object in session in a servlet using
              > session.setAttribute() but when i try to retrieve that object using
              > session.getAttribute() in a jsp page the value of that object is null. Is
              > there any way to configure HttpSession in weblogic so that jsps and
              servlet
              > can share the same session? Or any workaround for this problem.
              > Any help in this regard is appreciated.
              > Thanks
              > -Shree
              >
              >
              

  • Choice between JSP and Servlet

    I am new to JSP and Servlet. I know JSP container will convert JSP to servlet
    eventually. But in application development's standpoint, anything can be
    done in servlet can also be done in JSP? Some people told me we can
    use the combination of both in one application.
    My question is in what situation we use JSP alone, servlet alone, or
    combination of both??
    Please advise. Thanks!!

    Use a combination of both.
    Your Web application should have a single servlet that all HTTP requests are POSTed to. All the servlet does is act like a traffic cop: it figures out what the request is, delegates to other objects that do the work, and forward the result to the next JSP, whatever that is. It's called a front controller servlet.
    The JSPs should just be pure dynamic presentation. Everything displayed in the pages should have been generated by the servlet and its helper classes. No database queries, etc. Your JSPs will be a lot better off if you learn JSTL and eliminate all scriptlet code.
    Check out frameworks like Struts.

  • What's the difference between *.JSP and *.DO?

    Hi. I'm new to JSP programming and noticed that form actions call something like pageName.do -- what's the difference between the .JSP and .DO? When do you call one vs. the other? Thanks.

    A request including the jsp extension usually refers to a single JSP file on disk that will be loaded and rendered directly.
    A request including the do extension usually refers to a call into a special servlet that will redirect the request to another "controller" class which will in turn do some processing, and then load one or more JSP files to render the response.
    The commonest form of the latter is the usage in the Struts framework. The do extension is not mandatory, it just presents a convenient way to distinguish calls that should be handled by Struts from requests for JSPs and other content that are mostly handled by the container (e.g. Tomcat) directly.

  • Difference between .jsp and jspf in weblogic

    Hi,
    A small question, what is the difference in behaviour between a jsp and jspf when doing a jsp:include.
    What is the solution when wanting to have a dynamic url to for example an image
    <img src="<%=imagepath%>image.gif">
    this works when the included file is a jsp but not when a jspf then it outputs "<img src="<%=imagepath%>image.gif">"
    Cheers,
    Johan

    >
    I am short describing the problem again,
    IN JSP, MY CODE IS LIKE THIS:
    HttpSession oSession=request.getSession(true);
    oSession.setAttribute("batchHash",reqRows);
    IN SERVLET, MY CODE IS LIKE THIS:
    HttpSession oSession=req.getSession(true);
    tblSession = (Hashtable)
    oSession.getAttribute("batchHash");
    System.out.println("IsNew ="+oSession.isNew());
    System.out.println("Object="+prmSSO);
    If I deploy this in TOMCAT, my output is like this:
    IsNew =false
    Object=Hashtable@982fc1
    If I deploy this in WEBLOGIC 6.1, my output is like
    this:
    IsNew =true
    Object=null
    Why is this?
    Why the "oSession.isNew()" returns "false" in tomcat
    and "true" in weblogic ?
    Please help....Your only problem is using
    HttpSession oSession=req.getSession(true);instead of
    HttpSession oSession=req.getSession(false);in your servlet! getSession(true) - forces to allocate new session,
    so it's absolutely clear why your Hashtable is absent in
    a newly created session!!
    Paul

  • Difference between JSP and tagdependent bodycontent in JSP Custom tags?

    Hello All,
    Can anybody tell me difference between the values of bodycontent attribute we mention in tld file?
    Can you give me some examples that practically show difference ?
    Also i want to know about BodyContent.
    Thanks in advance.

    Hi,
    I am a little confused about your point 2...... Why do you think it is not compatible?
    Well, the thing is: cause JSP is based on HTML it was easier to build nice user interfaces - and AWT always looked a little strange. As well it was easier to adapt JSP to other layout styles to run the same app on Lapotop/PDA. At the end that is pretty much it.
    MI is based on the SyncBO concept - so if you access a SyncBO in JSP or in AWT MI makes no difference and so at the end all that counts is: are you happy with AWT layout or do you need something more native/fancy/..... Well, AWT is limited in some areas - JSP give you much more. That is all limited due to the fact that up to MI7.0 MI runs on Creme with JRE1.1.8 support only.
    But MI7.1 now supports JRE1.4.2 even on PDA - and so we have SWT available - and so in 7.1 the default UI is SWT (very very basically we could say, this is the AWT direction - but really only if we really want to compare 7.0 and 7.1)
    Hopefully you got it.
    Regards,
    Oliver

  • Usage difference in JSP and Servlets

    Can someone explain when a servlet is used against JSP and vice versa?

    I think Servlet is more convience to communicate with javabean, when handling a large number of variables.
    For example, a html form post a 2D array of variable.
    Then you may find diffcult to past these variable into a bean using JSP.
    Also when you diffcult to separate the html and java code in some JSP page, then it is better to use servlet.
    On the other hand, the advantage of JSP is that it doesn't require user to complie the source code by hand, more suitable for some page that is always changing.

  • Passing parameters between JSP and Servlet

    The scenario is as follows:
    There is a JSP page that sends a string as a hidden parameter to a servlet:
    <input type="hidden" name=<%= Book.NAME %> value=<%= book.getName() %> >
    In the servlet there is a print statement that checks the parameter value:
    System.out.println("Book name: "+request.getParameter(Book.NAME));
    The problem is as follows: if the name of the book consists of more than one word
    such as "Servlets and JSP", the print statement will print only Servlet.
    If the JSP page passes a string directly as shown here:
    <input type="hidden" name="Test" value="Test String" >
    The servlet will print the complete string: Test String
    The same problem appears if the string is passed between two JSP pages.
    Any help is greatly appreciated.
    Regards,
    Basil Mahdi

    You might want to try
    <input type="hidden" name="<%= Book.NAME %>" value="<%=URLEncode.encode(book.getName(), "UTF-8")%>" >This will take care of any wierd un-url friendly charcters that might appear in the book titles such as the ' or " which may be the problem.

  • Difference between JSP and AWT applications in MI

    HI,
    Can anyone plz clarify the difference and specific use of AWT n JSP appl in MI.
    As far as i understand:
    1)JSP works on browser based UI whereas AWT uses native UI.
    2)AWT is faster dan JSP but not compatible with SAP appl.
    3)We use AWT in appl like DSD n JSP in MAM,MSR etc.
    Plz explain in detail wat r the scenarios in which AWT can be used??
    Regards
    Priyanka

    Hi,
    I am a little confused about your point 2...... Why do you think it is not compatible?
    Well, the thing is: cause JSP is based on HTML it was easier to build nice user interfaces - and AWT always looked a little strange. As well it was easier to adapt JSP to other layout styles to run the same app on Lapotop/PDA. At the end that is pretty much it.
    MI is based on the SyncBO concept - so if you access a SyncBO in JSP or in AWT MI makes no difference and so at the end all that counts is: are you happy with AWT layout or do you need something more native/fancy/..... Well, AWT is limited in some areas - JSP give you much more. That is all limited due to the fact that up to MI7.0 MI runs on Creme with JRE1.1.8 support only.
    But MI7.1 now supports JRE1.4.2 even on PDA - and so we have SWT available - and so in 7.1 the default UI is SWT (very very basically we could say, this is the AWT direction - but really only if we really want to compare 7.0 and 7.1)
    Hopefully you got it.
    Regards,
    Oliver

Maybe you are looking for