Newbie JSP/Servlet general question

Hi,
I am currently studying the life cycle of a JSP page from the Java EE 5 Tutorial (http://java.sun.com/javaee/5/docs/tutorial/doc/bnahe.html). This document says that: "+If an instance of the JSP page’s servlet does not exist, the container loads the JSP page’s servlet class, instantiates an instance of the servlet class, initializes the servlet instance by calling the jspInit method+".
My two questions are:
i) Does this JSP servlet implement the HttpJspPage interface defined in javax.servlet.jsp?
ii) Does Struts and Spring MVC provide such JSP servlet Java classes implementations or are these part of other packages? If not, which packages offer such implementations?
Thanks,
J.

Jrm wrote:
Hi,
I am currently studying the life cycle of a JSP page from the Java EE 5 Tutorial (http://java.sun.com/javaee/5/docs/tutorial/doc/bnahe.html). This document says that: "+If an instance of the JSP page’s servlet does not exist, the container loads the JSP page’s servlet class, instantiates an instance of the servlet class, initializes the servlet instance by calling the jspInit method+".
My two questions are:
i) Does this JSP servlet implement the HttpJspPage interface defined in javax.servlet.jsp?Yes.
>
ii) Does Struts and Spring MVC provide such JSP servlet Java classes implementations or are these part of other packages? If not, which packages offer such implementations?No, the implementation for the JSP servlet is usually provided by the Servlet Container, not a framework, since the Servlet Container is responsible for creating and compiling the JSP.
>
Thanks,
J.

Similar Messages

  • Jsp,servlet,bean question,please help

    The Tomcat Web server set up like this.......
    The directory structure is
    e:/sampleapp/WEB-INF/classes
    /lib
    And the web.xml is in the WEB-INF for the use of ay potential servlet.
    The basic understanding is that all the .java files go into the WEB-INF directory and the .class files go into the classes directory.
    All the .jsp files go into the sampleapp directory.Till here is correct I feel.
    Now for my qustion......
    I plan to use jsp,servlet and beans for a potential web application...,where do all these files go?,just the same as above or is there a difference.
    Hope that I have given a reasonable explaination to my question.
    Thanks for any replies
    AS

    All of your compiled servlet and java bean (java
    classes in general) will be placed into the following
    directory (under a directory structure matching the
    java package they are in):
    e:/sampleapp/WEB-INF/classesAll of your .jar files that are used as libraries (not
    your .jar files for applets):
    e:/sampleapp/WEB-INF/libAll of the rest of your JSP files, javascript files,
    HTML files, JAR files, images files, etc. will go into
    the following directory:
    e:/sampleappYou must make sure you put your sampleapp directory
    where tomcat can load it. Or use the admin tool to
    load it. If you make a .WAR file with a corresponding
    web.xml file in it, it will simplify loading it into
    tomcat. It also will help you do your servlet
    mappings, etc. I hope this helps.Thanks for your timely response.To add to it,let me tell you.
    The <b>bean</b> files are put into a package right,so they should be put into the WEB-INF/classes/<package name>
    What about The <b> servlet </b> files...... they are just put into the WEB-INF/classes/ directory????
    Kindly let me know.
    Thanks
    AS

  • Question about domain name/JSP, servlets

    I have a web host which publishes my pages, say www.zzz.com. I want to use JSP/Servlets on my machine which is using Apache Tomcat. Here's the problem, if I link a JSP/Servlet from www.zzz.com, the user will see my IP, i.e. 37.28.18.102/servlets/Calculations
    Is there a way where the people's browser's URL text field will always be www.zzz.com even if the page is located on my server?

    Try using Frameset where top frame is always www.xxx.com and child frame can be anywhere

  • Newbie question - general question about e-mail sync

    Hi,
    I have a general question about email sync and BlackBerry smartphones.  Are there any devices that allow email syncing with a Microsoft Exchange 2007 system that do not require the BlackBerry Enterprise server?
    Thanks; sorry if this has been asked before but I was unable to find it in the forums, documentation, etc.  Everything I found assumes that for this kind of environment you will be using a BlackBerry Enterprise solution, but I can't assume.
    Thanks again.
    Solved!
    Go to Solution.

    Hi and Welcome to the Forums!
    If the Exchange server has anything that faces the internet (OWA, POP, IMAP), then BIS can be used to handle email (only email...calendar and contacts require BES to sync OTA).
    Or, a PC, inside the network (but with an internet path) and logged into the email server (using Outlook), can be left running, using the RIM Desktop Software's Desktop Redirector capability to forward  messages to the BB.
    Those are basically the options.
    Hope that helps! Let us know!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Can somebody explain to me how JSP, servlets, ASP work within Sun's server

    Ok, I'm only beginning to get a grip of how all this works. And I have a lot of questions and confusion.
    1.) The server that comes with J2EE, what is that server? Is it an app server that runs only servlets and JSP, with some Web server stuff so it can output some info? Is it a stripped down version of TomCat? I am having a lot of trouble with the J2EE server (the one that comes with the SDK), and that is why I'm asking, maybe I don't need it. But I really want to learn JSP's, JScripts, and Beans. How else can I go about doing that, other than all out Tomcat.
    2.) Also can I run Servlets on Microsft's IIS on a Windows 2000 machine? Do I need a special API to run servlets, or JSPs?
    So how I see it, and again, I am a newbie at this. Machines that host a website, above all needs a web server. let's say most people use Apache, and they want to run it in Linux, becuase they want to be hackers. So then do they also run Tomcat, or IIS, or Coldfusion, or a million other servers in tandem on the same machine, so that they can handle ASP, JSPs, servlets, .cmf, etc.? or do they separate the app server from the webserver and then do some sort of linking? if somebody can direct me to how all this stuff works, I would greatly greatly appreciate it.

    Sounds like you need to read the J2EE spec as well as
    the servlet and JSP specs. It helps to glance through
    sections you are interested in.
    Ok, I'm only beginning to get a grip of how all this
    works. And I have a lot of questions and confusion.
    I think for a newbie, deploying your jsp's and servlets
    to a J2EE compliant app server can be quite a headache.
    You might want to concentrate on tomcat, which does servlet
    and jsp.
    Some app servers provide a http connector for most common web servers.
    I think tomcat has a IIS connector. In this case IIS would serve static html as well as its own stuff, other things like servlets and jsp go to tomcat. I am unsure about this as I mostly use tomcat in standalone mode. You can run tomcat on windows, as it is written in java.
    >
    2.) Also can I run Servlets on Microsft's IIS on a
    Windows 2000 machine? Do I need a special API to run
    servlets, or JSPs?

  • How to implement this function in JSP/Servlet env?

    Hi all,
    I working on a project, it provides functionality to upload file using JSP/Servlet. In the first JSP page, there is file location and submit button. After user select a file to upload and click submit button, a message, like "sending file to XXXX", will be shown on the screen. Once uploading and validation are done on the server-side, a successful/error msg will be shown to user.
    Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?
    Thanks for any help!
    Tranquil

    For the sending message... Well, the thing is, when you click submit, it's sending the file to the server and the server is processing it, and this is all done before the "complete" page is sent to the server. So one would need to use some Javascript on the page before the actual submit happens to show some message. This is done on Ebay when you put something for sale, you can upload an image, and there is a little popup message telling you that it's uploading, and it is removed when the process is done. Now, I'm not sure the exact details of how this works, but my educated guess is this:
    1) The onsubmit function of the form checks that the file upload fields have a value (no need to popup a message if no file upload, since that's what usually takes the time, although it could just be assumed there is a file). If a file is to be uploaded, or just want to show the message anyway, a new popup window is opened with the window.open method and the "sending" message is shown (either written via Javascript or just load a small web page to the window).
    2) The popup window, since you can't transfer the window object from the form page to the next page, has to check window.opener for some value that the success/error page would have to set. The success/error page could use it's body onload function to set a variable in it's own window object to denote that the page is loaded. The popup window can use a looping check using setTimeout or setInterval in Javascript to check for window.opener.isLoadedVariable to be present, and if so, close itself.
    I've never done that, but I see no reason why it wouldn't work.

  • File upload and download using jsp/servlets

    How to upload any file to the server using jsp/servlets. . Help me out

    You can also try the Jenkov HTTP Multipart File Upload. It's a servlet filter that is easy to add to your web-project. After adding it, you can access both request parameters and the uploaded files easily. It's more transparent than Apache Commons File Upload. There is sufficient documentation to get you started, and there is a forum if you have any questions.
    Jenkov HTTP Multipart File Upload is available under the Apache license, meaning its free to use.

  • Jsp / Servlet / bean / upload

    Hello,
    I use a jsp to enter several fields. These fields are sent to a servlet by using a bean (recorded in the current session). Until now there is no problem. The servlet receives all information. Now I must also send 5 files which must be stored on the server. I have thus to add in my jsp 5 file fields.
    My question :
    Is it possible to integrate the FileUpload package for uploader my files without anything to change in my code (by using of a bean to exchange the data between my jsp and my servlet). ??
    In other words, it is possible to use my bean to also transport files. ??
    Tank u for u help

    Yes it is possible..
    download cos.jar from www.oreily.com for file upload..
    it will read dat from the form as two parts ..
    parameter part and file part..
    and you can implement it throgh a servlet easily..
    for more follow oreily JSP/servlets Cookbook

  • JSP to Excel question

    Hi,
    I have a jsp page that renders data from a result set (queried from database).
    A button on this pages calls a 2nd page that I want to re-query and open excel with the data.
    This all works except that there are a number of blank likes at the top of the excel page, prior to my data. These relate to declatations at the top of my page. i.e
    <%@ page import="java.io.*" %>
    and
    <jsp:useBean id="AccountDetailsBean" class="com.xxx.yyy.zzz.AccountDetailsBean" scope="session" />
    This will give 2 blank lines. I assume that this is because they are essentially being treated as HTML comment lines.
    How can I avoid this? Can I declare these within the main JSP servlet?
    Thanks for any assistance.

    However, remember that the parameters in GET requests are logged in the
    server log so whatever information you send to the server via a GET, remains
    logged and available to whoever has access to your logs. Shouldn't be many,
    but should that information get to the people who run a log analyzer to get
    statistics on the server usage?
    POST is better because the parameters are sent in the body of the request
    and the body is not logged.
    SSL needs to be used in both cases.
    "Dror Avinun" <[email protected]> wrote in message
    news:3affe4b3$[email protected]..
    >
    All the SSL encryption is done in the socket layer and all of the HTTPcommunication
    is encrypted. This means that both the request (yout "GET" command) andresponse
    are secured.
    cheers,
    Dror
    "Asher Bitton" <[email protected]> wrote:
    Hi,
    I'm using https to call from an excel application to a weblogic jsp page,
    my question is whether the url that excel sends (for example:
    "https://mypc:7002/mydir/myfile.jsp?myvar1=val1&myvar2=val2")
    gets also encrypted\secured, what I'm interested to know is whether the
    parameters sent using the http "get" method are secure?
    Where can I find some information regarding the https implementation
    thanks.

  • JSP/Servlets & XML - suggestion needed

    Hi everyone,
    I don't have any coding issues, I'm really just looking for some help on deciding how to go with a project I want to make. First off, I wrote a Java library that builds messages in a special format. I wanted to come up with a pretty frontend for it, so I decided I'd try my hand at a webapp since I've been interested in them for a while. So far my web app consists of jsps, servlets and my library.
    At this point I'd like to add the ability for the webapp to store created messages in an XML file (read / write). The XML library I want to use is JAXB. I have it setup to read/write my XML file fine in a test servlet, however I'd like to implement this in a kind of "best practice" approach. So I'm looking for suggestions on how I should do this.
    A few of my ideas:
    1) Use a jsp page to call a "MessagesBean" which retrieves my data from my xml file. I could then format this nicely in the jsp page. The problem with this however is that I can't find any way to open a file relative to the webapp from within a Bean. ie. when I try to open "messages.xml", I can see from tomcat errors that it attempts to open it in tomcats bin folder (or if i run from within eclipse, eclipses bin folder). I know I could get around this by using an absolute path but I want this to be portable. Any suggestions?
    2) To solve the above problem I found "getServletContext().getRealPath("")" in the Servlet API. Using this method I'm able to open my XML file relative to my webapp. The only issue I have here is that I'm now using a servlet to display the page, making it harder for me to format the output.
    I'm very new to JSP/Servlets/etc so I really don't know how I should be doing this. I'm just trying to make sure I don't start out on the wrong foot. Can someone please give some suggestions on what I could do?
    Cheers.

    I suggested not putting business logic in the servlet, but instead instansiating a business logic object in the servlet and calling one of its functions to do the work.
    There is nothing wrong with putting the business logic in the servlet on first try. Just later on, you might want to refactor the code to more conform to the above.
    In your code, you mentioned that the MessagesBean in the JSP page doesnt seem to call the constructor. The <useBean> tag first looks to
    see if the object is in request scope. If it is, it uses it (doesnt call constructor). If its not, it creates its own (calls constructor). You should always
    have it in request scope ready for useBean to use.
    I think this line:
    <jsp:useBean id="messages" class="my.package.MessagesBean" />
    should be changed to something like:
    <jsp:useBean id="messages" class="my.package.MessagesBean" scope="request" />
    The MessagesBean should only have get/set methods to get data out of its object (its a very simple object that holds data). None of its functions
    should perform business logic such as hitting the database.
    Therefore these items in your JSP page should be in the servlet or business logic:
    messages.setPath( getServletContext().getRealPath("") ); // Pass in relative PATH
    messages.processXML(); // Process XML file
    While this should be in your JSP:
    java.util.List<TEXT> TextFiles = messages.getTEXTFiles(); // Return a List of TEXT objects
    Question: The JSP calls my Bean "MessagesBean". It then passes in the current relative path. This seems fairly hackish to me, is there a better way to give the relative path to my bean?
    Answer: Hard code the relative path to the JSP page in the servlet or business logic. There is no need for the JSP page to pass its path back to the servlet or business logic. Your servlet
    'knows' the path to all the JSP pages it needs to dispatch to.
    The best way to learn MVC is to continually refactor your code until it looks more and more like MVC (separation of concerns).

  • Sample jsp servlet bean (MVC) code

    We want to look into the JSP/Servlet/Bean area for our next project. We wish to understand the technology and as such want to hand build simple applications, and as such do not want to use JDeveloper just yet.
    We have searched and searched for suitable material but cannot anywhere find a sample application that :
    A. Lists contents of a databse table
    B. Each item in trhe list is a link to a page that allows that item, to be edited.
    C. A new item can be added.
    D. Uses the MVC model of JSP/Servlet and bean (preferably with no custom tags)
    There are examples that are too simplistic and do not cover the whole picture. Having spent over 100 GBP on books lately, only to be disappointed with the examples provided, we need to see some sample code.
    The samples provided by Oracle are too simplistic. They should really have provided ones built around the EMP and DEPT tables.
    Anyone know where we can get hold of this sample code.

    At the risk of sounding really dumb the examples are just too complex. There does not appear to be anywhere on the web where I can find a simple JSP/servlet/bean example of the type I described. There is enouigh material describing each individual component, but what I need is an example to cement the ideas, but the ones suggested are too much for a newbie. Even the much vaunted Pet Store thingy causes my eyes to glaze over.
    I dont expect anyone to have written something with my exact requirements, but surely to goodness there must be something that:
    1. On entry presents a search form on a table (e.g. EMP)
    2. On submission list all rows in EMp matchiung the criteria.
    3. The user can either click the link 'Edit' which opens up a form dispalying the row allowing the user to edit and save the changes, or click the 'New' button to show a blank form to create a new EMP.
    All this via a Controller servlet, with the database logic handled by a java bean, and all the presentation done via JSP.
    To me this is the most obvious and instructive example of this technology, but after days of trawling the web, and looking through a number of books, I cannot find such a thing.
    CGI with Perl DBI/DBD was a breeze to work with compared to this stuff ..... maybe ASP with SQL/Server would be a more fruitful use of time.

  • Change Drop Down from Other JSP/Servlet/Bean

    I am wanting to have a select box populate from a database query based on the information pulled from another select box as the user chooses it (ie a user chooses a state and the city choices populate or something like that). I am using JSP, Servlets and Beans. Seems that I need to us JSF, but I was wondering if there is another way or better way.
    Thanks for the thoughts.

    user12081556 wrote:
    I meant to put in my question above, aren't jsf tags just imbedded in some jsp/html code?Not jsp code no. I don't know whether it's possible to use jsf and jsp together, but I wouldn't try.
    While JSP has evolved over time from Html and Java code mixed together to standard tags responsible mostly for displaying the data, it's still an old "hack" that compiles jsp pages into servlets.
    JSF at least alleviates some of those problems and works nicely with proper xhtml formatted views too (and there's facelets etc. etc. etc.).
    Granted, if you're shown some jsp tags and jsf tags, you might not appreciate the difference in the technologies.

  • Menu item in Jsp/Servlet

    Hi experts, when you're using Jsp/Servlet to implement the front-end web application, what options do you have for implementing some menu dropdown?
    Is awt or swing can be used for that purpose?
    How would you go about the layout management issue?
    Thanks, and your reponse is appreciated

    I guess You are looking for a solution in JSP/Servlets. Here is my program that might be help ful to you. This program will bring a drop down list that fetches the values from the database.
    <table cellpadding=4 cellspacing=2 border=0 align=center>
    <TR>
    <TD><B>choose Code</B></TD>
    <TD valign=top>
    <!-- this code is to generate the list of Codes-->
    <% String userId =(String) session.getValue("userName"); %>
    <%
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;
    String uId;
    String returnString="";
    String null_value="";
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@serverName:1521:localHost", "scott", "tiger");
    if (con == null) {
    System.out.println("Connection not found");
    stmt = con.createStatement();
    con.setAutoCommit(false);
    String sql= "select code from example_list where user_id='"+userId+"'";
    rs= stmt.executeQuery(sql);
    %>
    <select name="alcList">
    <%String aString;
    rs= stmt.executeQuery(sql);
    while (rs.next()) {
    %>
    <option value="<%= aString = rs.getString("code") %>">
    <%= aString %></option> <%}%></select><%
    con.commit();
    //returnString= true;
    } catch(SQLException sqlex) {
    sqlex.printStackTrace();
    //return returnString;
    } catch(Exception ex) {
    ex.printStackTrace();
    } finally {
    stmt.close();
    con.close();
    stmt = null;
    rs = null;
    con = null;
    %></TD>
    <TD align=center>
    <INPUT TYPE=submit SIZE=30 VALUE="Submit"></TD>
    </TR>
    </Table>
    </FORM>
    </BODY>
    </HTML>if this doesn't answer your problem, Please post your question exactly. May be I can help you out.
    Good Luck.
    -Sreekanth varidhireddy

  • JSP.Servlets ....

    I am working on a application where I have JVM on Power PC hardware with Linux as OS. I have also configured Apache and Tomcat and everything is running fine. I can execute example servlets as well jsp pages.
    My objective is to have java lib or jsp servlet (something) which will read /write data from Power PC and then pass it on to Host (Windows Application as well the web application
    Question: how does my Host app written in VB NET or C# will retrieve this data form Power PC? The reason I want this way as i do not want to write Power PC data read/write code twice , one for website which will run on my Power PC and then second host applciation running on windows.
    I hope I am making my point clear., any help or suggestion appriciated
    Thanks
    AGDT.

    I am working on a application where I have JVM on
    Power PC hardware with Linux as OS. I have also
    configured Apache and Tomcat and everything is
    running fine. I can execute example servlets as well
    jsp pages.Very good.
    My objective is to have java lib or jsp servlet
    (something) which will read /write data from Power PC
    and then pass it on to Host (Windows Application as
    well the web applicationJava JVM running on Power PC or Windows can read or write data for that OS without a problem.
    Web apps accept HTTP requests. HTTP protocol is the same for both Windows and PowerPC. What does the web app have to do with this?
    Question: how does my Host app written in VB NET or
    C# will retrieve this data form Power PC? Now I'm confused: Which is the host, which is the client, and where are the servlets and JSPs in all this mess?
    The reason
    I want this way as i do not want to write Power PC
    data read/write code twice , one for website which
    will run on my Power PC and then second host
    applciation running on windows.What is the Windows host? Is it also an HTTP listener that you want the servlet to connect to and send data via HTTP?
    I hope I am making my point clear., any help or
    suggestion appriciated
    Thanks
    AGDT.Clear as mud to me. Perhaps you can explain it a little better, or someone else smarter than me will see what you're driving at.
    %

  • Programmatically Registering a JSP/Servlet Portlet

    ???Programmatically Registering a JSP/Servlet Portlet???
    OK, I have read all the literature on how to register a JSP/Servlet Portlet and have not seen any info on how to register a JSP/Servlet Portlet programmatically.
    I know for sure that you can register a PL/SQL Portlet programmatically via a couple of SQL and PL/SQL scripts that were given in the PL/SQL PDK examples.
    Bottom line, I want a way to register a new JSP/Servlet Portlet with ZERO GUI/User interface.
    My questions are:
    Is it possible to register a JSP/Servlet Portlet programmatically?????
    If it is possible to register a JSP/Servlet Portlet programmatically, were is the info on it or can you give me some examples of it????
    THANKS MUCH!!!
    null

    For a faster response, you may want to ask this question on the Portal Developer's Kit (PDK) Forum.

Maybe you are looking for

  • Using web services with flash cs3 and actionscript 3.0

    Hi, I want to use web services under flash cs 3 and by using as 3.0. It was possible with as 2.0 to do it easily thanks to the webservice Connector. But I can't find how to use web services under flash and as 3.0. I thought web services took part of

  • FI Objects button not displaying for Cust Disputed Objects -- Dispute Mgmt

    Hi FI Objects button is not displaying on a dispute case processing screen for Customer Disputed Objects. Help in this regard is highly appreciated. Thanks Rajanikanth

  • [solved]Sudo asking for password when it shouldn't through a sh script

    Bottom of my sudoers file looks like this: user username = (root) NOPASSWD: /usr/bin/g15daemon user username = (root) NOPASSWD: /usr/bin/g15stats Shell script looks like that: #!/bin/sh sudo /usr/bin/g15daemon -k & sleep 2 && sudo /usr/bin/g15daemon

  • Get_selected_rows doesn't work for second time

    I have a custom screen with an ALV output and some push buttons. When I select one of the rows in ALV and click on a pushbutton, it does go the next screen. But, if I come back and select another row in ALV, the table parameter <b>ET_ROW_NO</b> retur

  • Charts question / limitation?

    I have been tasked with pulling together a chart that conveys results of a customer satisfaction survey that contains 6 questions.  Each question has a measurement score on each of 1 to 5. What I am trying to do is for each question, I want to stack