Second request to a JSP page

When a second request is made to the JSP page, is the request sent to the servlet directly or is it handled by the JSP page. The question comes bcos when the JSP page is requested for a second time, a copy of the .class file is already available in the servlet container.

hello,
Even the first "request" is handled by the generated servlet! On to point, The JSP page GETS COMPILED ONLY ONCE after you install/modify it ,or on restart of server.Once a request is send to the jsp page ,the server checks for the time flag of the JSP file,and if it finds that the jsp page is modified,it recompiles the page,and send the request to the generated servlet for processing.Else it handles over the request to new servlet instance of precompiled servlet class.Note the diff in latency when you first call the JSP page and subsequent calls.This is because of foresaid reason.
Just 4 fun try deleting the .class files in works folder,if u work on a tomcat.
cheers
[email protected]

Similar Messages

  • Display request contents in JSP page

    i need to display the contents in a request in my JSP.
    meaning:
    i have a hashmap (containing string and a list) coming from the EJB tier to struts action in an event response object, I'm sure that the request has these values. cuz i tested it in struts action using the following code:
    HashMap result = (HashMap)((EventResponseSupport)request.getAttribute(WebKeys.EVENT_RESPONSE)).getPayload();
    System.out.println("Sponsor name = " + result.get("sponsor"));I am able to print it in the console but i need to know how to display it in the jsp. i tried many things but i can't get it right.
    first i need to display the string and then i need to iterate through the list to display its contents in a table.
    any help would be appreciated.

    Kindly use JSP Scriplet to load the HashMap into the Page Context.
    Then you can use the Struts iterate tags to paint the contents of the HashMap

  • Request dispatcher and jsp pages called from servlets

              Given the following webapp directory structure:
              root/
              jsp/
              ..all jsp files
              web-inf/
              classes/
              /servlets
                   ..all servlet files
              /com
              ..all other java class files
              I have the jsp directory coded as: jspdir = "/jsp/" (and have tried variations
              on this theme)
              I try to open a new jsp page with the following code in a servlet in the above
              servlet directory:
                   RequestDispatcher rd;
                   rd = getServletContext().getRequestDispatcher(jspdir + myjsp.jsp);
                   rd.forward(req, res);
              rd continues to return null.
              The jsp pages are not registered in the web.xml file for this webapp, if that
              makes any difference.
              Does anyone have any suggestions?     
              [problem.txt]
              

    I create a small sample and put these files into /jsp in my war context
              it works fine, please send me the example code you are using and the
              environment description of the deployed application
              I attached my samples, that work
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "Bill Blackmon" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Yes, I am able to access the jsp pages with the url listed.
              >
              > "Filip Hanik" <[email protected]> wrote:
              > >The weblogic servlet engine, is by default mapping anything that ends
              with
              > >*.jsp to be a JSP.
              > >so there shouldn't be a problem. You didn't answer my first question,
              > >are you able to access your JSP through the browser?
              > >http://localhost:7001/root/jsp/myjsp.jsp
              > >
              > >Filip
              > >
              > >--
              > >~
              > >Namaste - I bow to the divine in you
              > >~
              > >Filip Hanik
              > >Software Architect
              > >[email protected]
              > >www.filip.net
              > >"Bill Blackmon" <[email protected]> wrote in message
              > >news:[email protected]...
              > >>
              > >> The code you are reading in the message here was pasted in and
              > >> looks bad, so maybe that's what you are referring to? The dispatcher
              code
              > >is called
              > >> in the service() method of the servlet.
              > >> I have a suspicion that the jsp directory needs to be defined someplace
              > >-
              > >weblogic.properties
              > >> or web.xml?, though I don't see this in any of the examples that come
              > >with
              > >the product.
              > >>
              > >>
              > >>
              > >> "Simon Ng" <[email protected]> wrote:
              > >> >
              > >> >Hello Bill,
              > >> > Did you put a <BR>
              > >> >return;
              > >> ><BR>
              > >> >statement right after the dispatcher.forward() statement? Well, I am
              > >assuming
              > >> >your
              > >> >code is in the doPost() or doGet() methods.
              > >> >
              > >> >Simon
              > >> >
              > >> >
              > >> >"Filip Hanik" <[email protected]> wrote:
              > >> >>if you do http://localhost:7001/root/jsp/myjsp.jsp
              > >> >>
              > >> >>do you get a result?
              > >> >>
              > >> >>make sure you have the right character case on the filename.
              > >> >>
              > >> >>Filip
              > >> >>
              > >> >>--
              > >> >>~
              > >> >>Namaste - I bow to the divine in you
              > >> >>~
              > >> >>Filip Hanik
              > >> >>Software Architect
              > >> >>[email protected]
              > >> >>www.filip.net
              > >> >>"Bill Blackmon" <[email protected]> wrote in message
              > >> >>news:[email protected]...
              > >> >>>
              > >> >>> Given the following webapp directory structure:
              > >> >>> root/
              > >> >>> jsp/
              > >> >>> ..all jsp files
              > >> >>> web-inf/
              > >> >>> classes/
              > >> >>> /servlets
              > >> >>> ..all servlet files
              > >> >>> /com
              > >> >>> ..all other java class files
              > >> >>>
              > >> >>>
              > >> >>> I have the jsp directory coded as: jspdir = "/jsp/" (and have tried
              > >> >>variations
              > >> >>> on this theme)
              > >> >>> I try to open a new jsp page with the following code in a servlet
              > >in
              > >> >the
              > >> >>above
              > >> >>> servlet directory:
              > >> >>> RequestDispatcher rd;
              > >> >>> rd = getServletContext().getRequestDispatcher(jspdir + myjsp.jsp);
              > >> >>> rd.forward(req, res);
              > >> >>>
              > >> >>> rd continues to return null.
              > >> >>>
              > >> >>> The jsp pages are not registered in the web.xml file for this
              webapp,
              > >> >>if
              > >> >>that
              > >> >>> makes any difference.
              > >> >>>
              > >> >>> Does anyone have any suggestions?
              > >> >>>
              > >> >>
              > >> >>
              > >> >
              > >>
              > >
              > >
              >
              [filipInclude.jsp]
              [filipForward.jsp]
              [filip.jsp]
              

  • Best practice of getting request parameters in JSP page

    int period_Id = 0;
    try
    period_Id = Integer.parseInt(request.getParameter("period_id"));
    catch(Exception e)
      period_Id = 0;
    }This is the normal way we use to get parameters from previous page.
    But I am not sure if it is thebest practice.
    Please respond if anyone knows a better way.
    Regards

    Using java code in a JSP is a horrible practice. There are far better ways to write JSP's nowadays in the form of custom tags, JSTL and possibly JSF. Combined with servlets this will make your code clean, reusable and maintainable.
    However if you insist and using scriptlets, I'd say create your own request bean that wraps around the HttpServletRequest and write methods getParameterInt(), getParameterDouble(), etc. Such a method could look like this:
    public int getParameterInt(String name, int default)
    String paramstr = request.getParameter(name);
    if(paramstr == null || paramstr.length() == 0){
      return default;
    try{
       return Integer.parseInt(paramstr);
    } catch(Exception e) {
      return default;
    }With such a bean you never have to do that exception catching yourself again: you can just pass the parameter name and a default value that will be returned if the parameter does not exist or is not a valid integer.

  • Getting troubles in getting the JSP page

    hi friends,
    Let me tell u first i m using Tomcat 5.5 and Internet Explorer .
    I think i have some problem in Tomcat. Coz I have made an JSP page which has a simple coding as follows
    <%@ page language="java" contentType="text/html" %>
    <html>
    <body bgcolor="green">
    <font size=5 color="red">
    <%! int i=5%> <%= "The i value is  "+i %>
    <h1>Let's cheak if its working or not. </h1>
    </font>
    </body>
    </html>Let me tell u i don't want to do anything ,except getting valid response from a JSP page.
    i believe nothing is wrong with this page but when ever i m giving request for JSP page i m getting a blank page(a page of white colour though i have set bgcolor to be 'green'). But if i m giving request for Servlet and HTML pages then it's running fine . Can anyone advice me what to do.
    Let me tell u one more thing i.e when i m giving request 4 a JSP page the corresponding Servlet (the java file as well as .class file) is being formed by Tomcat. But still i m not getting my output.
    I hope i m clear in communicating my problem.
    Please suggest some solution what to do.
    with regards
    Arunabh

    save the above as test.jsp ..place it in webapps....
    important thing is check the path name u give in ur
    url
    http://10.32.246.55:8080/Activit/tex.jsp... in
    my system i have a folder called Activit in webapps
    so no need to mention webapps in url.... mention the
    ip address ..if u r runnin the application on the
    system where tomcat is installed then instead of ip
    address u can mention as localhost .. do
    mention port no. also ... think by default port no is
    8080...
    it should work cauz it worked in my systemIf it worked in ur system then i suppose somthing is wrong with my tomcat. Is it so ?????
    Arunabh

  • Two Identical forms on the same JSP page.???

    Hi want to have two identical submit forms on the same form but for some reason a get a javascript error when i add the second form to the JSP page... can you help me...

    I assume you meant "two identical submit buttons", instead of "two identical submit forms". Seeing your description of the problem, I believe you can reproduce it with a pure .html page, that is, a page containing not JSP code. So it is not a problem in JSP domain proper.
    I was going to direct you to the Technologies>>Internet>>Dynamic Services forum at
    http://forums.oracle.com/forums/thread.jsp?forum=95
    Then I found you have posted the same question as thread 298169 there.

  • In JSP pages request.getParameter returns null

    There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
    Code :Ist jsp
    <BODY>
    <HEAD>
    function validate()
    document.add.submit();
    </HEAD>
    <FORM name="add" method="post" action=/dir/two.jsp" >
    <TABLE width="37%" border="0" align="center" class="c4f3">
    <TR>
    <TD class="c4">Rating</TD>
    <TD><input type=text name="rating"></TD?
    </TR>
    <TR>
    <TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
    </TR>
    </TABLE>
    </FORM>
    </BODY>
    After the submit it goes to the 2nd JSP page .
    code:2nd Jsp
    <%
    String Rating=request.getParameter("rating");
    out.println(" Rating "+Rating);
    %>
    The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
    Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
    Thanks

    If I'am right you have misplaced the opening body-tag of your first jsp-page.
    The opening body-tag should follow after the closing head tag .
    The structure of your HTML-code should look like this:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all,
    i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
    Output :
    FILE NAME : TEST
    FILE PATH : test.txt
    Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileReader.<init>(FileReader.java:55)
    at com.test.TestServlet.processRequest(TestServlet.java:39)
    at com.test.TestServlet.doPost(TestServlet.java:75)
    JSP CODE:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!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>DEMO SERVLET</title>
    </script>
    </head>
    <body>
    <h2>Hello World!</h2>
    <form name="myform" action="TestServlet" method="POST"
    FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
    FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
    <input type="submit" value="Submit" name="submit" />
    </form>
    </body>
    </html>
    Servlet Code :
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    String filename = request.getParameter("filename");
    out.println(filename);
    String filepath = request.getParameter("myfile");
    out.println(filepath);
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TestServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
    if (filepath != null) {
    File f = new File(filepath);
    BufferedReader br = new BufferedReader(new FileReader(f));
    String strLine;
    String[] tokens;
    while ((strLine = br.readLine()) != null) {
    tokens = strLine.split(",");
    for (int i = 0; i < tokens.length; i++) {
    out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
    out.println("----------------");
    out.println("</body>");
    out.println("</html>");
    } finally {
    out.close();
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    Needed Output :
    FILE NAME : TEST
    FILE PATH : C:\\Temp\\test.txt
    Any suggestions Plz??

    As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
    You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html].

  • Can you open a second jsp page as popup/new window?

    Hi all gurus!
    I have a question regarding popups/new windows in an iview application. Instead of starting with a question let me instead describe what I want to do.
    We have a jsp page that presents a search and then the search result in a table where one column is "clickable". When the user clicks a cell a server round trip retreives data specific for that cell value. This is standard functionality and already fixed so here is what differes: we want a new jsp window to open like a popup, with the data retreived from the server round trip and at the same time the first page with the table shall still be there so that you just can close the popup and click the next cell which creates a new server round trip and a new jsp popup and so on.
    My solution which doesn't work yet: In application "a" I have a JavaScript for the clicked cell which opens another iview application "b" in a new window, by window.open("navurl_to_the_iview"), and that works fine.
    At the same time the value of the clicked cell is written to the data bean and the bean is put in the http session (since component session does not reach between applications).
    The second iview "b" retreives the bean from the http session and fills the jsp page with data.
    Here is now the problem: no data is displayed and this because the iview "b" retreives the bean BEFORE iview "a" has been able to put the bean/value into the http session. How do I know this for sure? Simple, if I do a refresh of iview "b" the value is displayed.
    I could do a JavaScript that recursively checks if the value in the bean is null or not but then I have to do a method that retreives the bean from the http session each time.
    This could work but I wonder if this is the most simple solution. So my question for you gents and madams is: do you know of a more simple solution?
    Best regards
    Benny Lange
    Edited by: Benny Lange on Oct 6, 2009 11:33 AM

    Hi you all.
    In this case the solution was to pass the id in the url to the second iview and let that iview use the id to retreive data from the backend system.
    But I still think the question is interesting, if it's possible to open a second jsp window after a server round trip and still have the first one open.
    All the best
    Benny

  • When I click on a yahoo news story, about 30 seconds into reading it, the page changes to one that says the page I requested can't be found, and it has a list of search results.

    I just upgraded to firefox 4 this morning. My homepage is yahoo.com. Sometimes when I click a news story, about 30 seconds into reading it, the page changes to a search result page with the heading that the page I requested can't be found. If I click the back button, it goes back to the page I was on. It doesn't happen on every one, and I haven't seen a pattern to which sites it happens on. It also happened when I was trying to make a payment on ebay.

    To revert to Google as your preferred search engine, please do the following.<br><br>
    * In the location bar, type '''about:config''' and hit Enter.<br><br>
    * In the filter at the top, type: '''keyword.URL'''<br><br>
    * Double click it and remove whatever's in there (probably Yahoo) and replace it with http://www.google.com/search?q=<br>
    The URL to add in "keyword.URL" becomes a link in this post, so right click it and choose "Copy Link Location" to copy it to the Windows clipboard. Then hit CTRL+V to paste it. Saves you having to type the whole thing.
    '''To reset your home page, do the following'''.<br><br>
    * Go to the site you want to set as your homepage.<br><br>
    * Click the orange Firefox button and go to '''Options '''| '''Options '''| '''General'''.<br><br>
    * Make sure it says "''Show My Homepage''" in the first dropdown menu.<br><br>
    * Click the button called "'''Use Current Pages'''" to set the homepage to the one you have on the screen.<br>

  • Error when requesting JSP page

    We have just finished getting our environment set up. We are running
    WebLogic 4.5.1 sp7 on a Sun server, and are frontending it with IIS 4.0
    SP6a using the iisproxy.dll WebLogic plugin.
    We can get things working for a while, but eventually, we get the
    following error in the NT event log when requesting the first JSP on our
    site:
    "Out of process application '/LM/W3SVC/1/Root' terminated unexpectedly"
    The Web server is still up, it's just when the JSP page is called that
    we get "Page can not be displayed" errors. Any HTML pages come up just
    fine. To fix the problem, we just stop and restart the Web Publishing
    service.
    Has anyone seen this error or does anyone know what events cause this
    problem?
    Thanks,
    -Mike

    There is a big difference between this;
    http://www.mydomain.com/blabla
    and this;
    http://www.mydomain.com/blah.jsp
    blabla - this is the name of the Web application. When you reference this Web application name Tomcat will check the welcom file descriptor and redirect for that web application.
    blah.jsp - is the name of a JSP page. When you reference this page the way you did above, you are not stating where the JSP page is located. It would be locatied in the "http://www.mydomain.com/blabla/blah.jsp" location.

  • Struts tag for request.setAttribute() in a jsp page

    Hello All
    Does anyone know struts tag that can be used for request.setAttribute() in a jsp page?
    Thanx in advance.

    Well
    <bean:define id="foo" name="newsIdAttribute" scope="request" type="java.lang.String" />is equivalent to
    <%
    (java.lang.String) foo = (java.lang.String)request.getAttribute("newsIdAttribute");
    %for setting bean properties you might have to use
    <jsp:setProperty/> or <c:set/> tags in JSP / JSTL respectively.
    Hope this might answer your question :)
    REGARDS,
    RaHuL

  • Request in JSP page

    Hi
    it east can be elementary what i ask but as even 2 days i test
    so
    it's just a request to acces base in JSP page
    at this level i get an integer variable numope who had value, and the the name of the column is Nope
    so the request is ("select * from body where Nope='numope' ");
    i tryed also ("select * from body where Nope=numope ");
    but the both it doesn't return a result, but if i test this with a variable it works
    the test is something like ("select * from body where Nope=49 ");
    i get a result i need
    thanks

    Construct the SQL string something like this:
    "select * from body where Nope=" + numope

  • Define a request attribute for a JSP Page

    Where do I need to define the request parameters
    that will be read by my JSP Page?
    If I have a JSP:
    <% String userName = request.getParameter("name") %>Where shud the attribute name be defined so that its value is read
    by the JSP Page?
    Does it need to be defined in the tag lib as an attribute?

    Where do I need to define the request parameters
    that will be read by my JSP Page?It can be a HTML form field in another JSP from which the request comes to this JSP. Alternatively, it can be a parameter passed through the URL like
    http://myhost/myapp/myjsp.jsp?name=Richard

  • Unable to load the second Jsp Page

    Hi,
    I have three jsp pages. The first is a Login.jsp which takes userid and password and after clicking on submit will take the user to the validate.jsp which validates the userid and password and if userid and password are valid redirects to a third jsp which has contentType="application/x-java-jnlp-file". All that is working fine, what is not working is after clicking on submit button I am not seeing validate.jsp page (i.e title and heading etc.), the browser stays in login.jsp page.
    Any suggestions.
    Thanks in advance.

    Hi
    Couple of things :
    1. Make sure that the "ACTION" sttribute in the FORM is pointing to the right URL.
    2. Make sure that the SUBMIT button is inside the FORM tags, then make sure that the SUBMIT button is in the same FORM as the Text Fields .
    If it is still causing you problems , please post your code.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc.
    http://www.sun.com/developers/support

Maybe you are looking for

  • Custom FM for getting subordinates in ESS Team Calendar

    Dear All, In the team calendar in ESS ,I want to use my custom Function module which gets the subordinates for the manger. Please tell how to proceed in this direction. Regards, Geet Bijlani

  • Location not shown on photos on ipad 4

    location not shown on photos on ipad

  • Classless netmask in Cisco RV 120 W

    I need to assign the mask 255.255.252.0 in the LAN interface but the web configurator does not allow it. The web configurator only permit assign the 255.255.255.0 netmask. My LAN segment is greater than 254 network devices and I cannot understand how

  • How to install Enterprise Manager alone 9i?

    Anyone, Is there an easy way to install the oracle Enterprise Manager on a PC without installing all the Web Server stuff that typically goes with the EM? I have tried custom install many times in past but I still end up getting Apache onto the machi

  • Illustrator CS3 Save as Postscript Issue

    Utilizing Illustrator CS3 on Mac OSX Tiger - Unable to output Postscript file. Getting the following error message: "The Save as PDF and Save PDF as PostScript options in the Printer dialog are not supported." However, we are able to output Postscrip