How does a JSP page send data to a servlet?

I know, elementary school question, but I can't seem to do it no matter what I tried to do. Here is my code:
       URL url = new URL("http://" + ChatGlobals.SERVER_NAME + "/" +
                ChatGlobals.SERVLET_PATH + "/ppowell.ChatServlet?message=" +
                URLEncoder.encode("/a " + cookieArray.getValue())
out.println("<P>" + url.toString());
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setDoInput(true);     // NOT REALLY INTERESTED IN INPUT BUT MUST BE TRUE
conn.setDoOutput(false);     // NO OUTPUT
conn.setUseCaches(false);
conn.setDefaultUseCaches(false);
conn.setRequestProperty("Content-type", "text/plain");
     * Do servlet connection to retrieve from ChatServlet URL instance
     * by instantiating an InputStreamReader object
     * @see ChatServlet
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String stuff = null;
stuff = in.readLine();
out.print(stuff);
in.close();
in = null;
conn = null;
Upon running this code my page just locks up.. URL: http://www.myjavaserver.com/~ppowell/chat.jsp
But if I call the servlet directly:
http://www.myjavaserver.com/servlet/ppowell.ChatServlet?message=/a+Phil
Everything works perfectly, no lockups, no errors, the log and txt files are created. So if my browser calls the servlet everything is ok, but my JSP script in the same directory as my servlet is the one that needs to call the servlet.
How then does a JSP send data to a servlet?
Please help, I've been searching in books and online resources for days now with absolutely no apparent luck to do it.
Thanx
Phil

It's correct that a JSP is compiled to a servlet. All HTTP servlets receive requests and send responses via HTTP, of course.
But this JSP is making a URL connection to a servlet and sending data.
Are you sure that the URL your JSP creates is identical to the one that works in your browser? Have you printed it out to stdout to verify that it's true? (Code inspection and "it looks right" doesn't count.)
Why are you doing it this way? It's common to have a JSP send to a servlet, but the usual way of doing it is to put an HTML form in the JSP, including an HTML <input type="submit">, and POSTing the form data to a servlet URL. Why aren't you doing that? - MOD

Similar Messages

  • How does a JSP page remember a user and prints in every page name of user?

    Hello, i'm working with JSPs and mysql.
    I have a Login page where sm inserts data in the two fields:
    name, username.
    i check if that user exists in the database.
    if the user exists i would like in every jsp page to mention/appear his name.
    As happens in this site [forums.sun.com] where it says "Welcome user" and
    when you click on it you are transferred in your profile page.
    How am i supposed to do that using JSP?
    May sm post me an example or a link to study that particular matter?
    thanks, in advance!

    This is covered by every decent JSP book/tutorial.
    Recommended book: [Head First Servlets & JSP|http://www.amazon.com/Head-First-Servlets-JSP-Certified/dp/0596005407] of Bates and Sierra.
    Recommended tutorial: [http://java.sun.com/javaee/5/docs/tutorial/doc/] (just Part II is enough).
    Alternative tutorials: [http://courses.coreservlets.com/Course-Materials/csajsp2.html].

  • How Does the Jsp Engine sense a changed jsp page

    Hi All,
    I would like to know how the jsp engine senses the change in .jsp page.Does it look thru the datetime stamp of the jsp page..
    can somebody plz help me on this.
    regards
    Karthik

    As long as the contents of the original JSP page remain unchanged, there is no need to generate a new servlet, since the Java code corresponding to those contents remains the same. For this reason, the very first step taken by the JSP page compiler when it receives a request for a JSP is to check the time stamp for the JSP file corresponding to the requested URL, to determine when that file was modified or created. The page compiler will also check the time stamp on the compiled servlet for this JSP page. If no compiled servlet is found, or if the time stamp on the JSP file is more recent than the one on the compiled page servlet, then a new servlet must be generated. This means that the (new or modified) JSP file must be parsed and translated into source code, and this new source code must be compiled. If the compiled servlet is newer than the JSP file, however, no new compilation is required and control can be transferred directly to the servlet to finish processing the request, saving considerable time. So while the first request for a new or recently modified JSP page will be slow, all later requests go straight to the compiled servlet for response generation.
    regards
    Vishnu

  • How to run JSP pages in weblogic 8.1 sp2

    hi frnzs,
    plese give me some idea about how to run JSP pages in weblogic server.

    enen i dont know hw to fly palne otherwise i can definitely give u sm guides abt that......

  • How do I convert or send data from a MacBook Pro to an s-video device???

    How do I convert or send data from a MacBook Pro to an s-video device??

    Use a Mini-Displayport-to-VGA adapter and a conversion box like this:
    http://www.amazon.com/PC-To-TV-Video-Converter/dp/B001CJOLBW/ref=pd_cp_e_2
    MBP

  • How does waveform graph downsamples the data before it is plotted

    Hi,
    I'm interested in how does waveform graph downsamples the data before it is plotted and what algorithm is used for this purpose? My goal is to plot 30 plots that have 1M samples each and I would like to downsample them before plotting onto a graph. I tried several VIs/algorithms for resampling and none of them gave the same result as seen by waveform graph (when all the samples are plotted).
    For example, if only one sample of 1M samples is 1 and all others are 0, then after downsampling to 1k samples the sample is not visible on the graph anymore. However, if I plot all 1M samples directly onto the graph, then also this 1 sample is visible (see attached example). 
    Solved!
    Go to Solution.
    Attachments:
    WFGDownsampling.vi ‏19 KB

    Hi andrej,
    LabVIEW draws plots in the way that draw every pixel affected by signal. So for example if there is zero-valued 1M samples and even one equals to 1, you will see the peak. That is the reason why you do not get the exactly same behavior comparing to interpolating. But if you set FIR as interpolation mode in Resample Waveforms (single shot).vi, result is really similar, but of course amplitude is 1000-times smaller than original one (because there is dt set to 1000). Keep also in mind that in Graph 2, there is different Y-scale and it should be considered as noise, not relevant data, I would expect 1000-times smaller amplitude as in Graph 3, it is many more times smaller.
    I would also like to say something about downsampling (decimating) the data. If you have 1M samples, you can see the peak even that there is only one value. But bigger problem is that with this graph resolution (I guess that is not more than 1000px), it is problem to find position of this peak. It means that still the zoom is needed to know where the peak is. Usually, when there is that big set of data, you are extracting different data (statistical information, peaks in FFT, etc.) not just visual data in graph.
    Mariaaa:
    I do not understand your question, can you please describe more your needs? You mentioned saving the data into a file, you can use Write to Measurement File express VI or see Write to Text File.vi in Example Finder and try to appropriately modify it.
    Best regards,
    Martin

  • How does one install page turning arrows in iBook author?

    How does one install page turning arrows in IBook Author?

    Hello Robert,
    I don't think such a feature exists within iBooks Author but it is a feature within ePub.
    So if you are viewing ePub books on an iPad the pages turn but if you are looking at books made with iBooks Author it is a page sliding.
    I will stand to be corrected here but I hope this helps some what.
    Regards,
    Nigel

  • How does replicate recover trail raw data to the true values?

    How does replicate recover trail raw data to the true values?
    or
    How replicate use the trail file?
    recover the trail file col values to a SQL?

    user5834416 wrote:
    How does replicate recover trail raw data to the true values?
    or
    How replicate use the trail file?
    recover the trail file col values to a SQL?GoldenGate "capture" (extract) parses the redo/archive logs and writes out trail data in a GG-specific, database independent format. The trail contains changed-data events: inserts, updates & deletes (and optionally DDL events.) The GG replicat reads this data and converts the data to SQL to be applied to the target.
    The GG trail files are not the same as the data as originally seen in the redo logs (GG is not doing any type of log-shipping of redo logs). The actual data in the trail isn't really important for end-users; it's an implementation detail (much like you shouldn't care what Oracle's redo log format is). But you can use "logdump" to inspect the contents of this (binary) file... again, kind of like LogMiner can be used to inspect archive logs.
    There are a number of (conceptual) analogies one can draw between Oracle redo logs & GG trail files. But they're not the same. Your questions are mostly internal implementation details that are not really important for understanding how GoldenGate works. Nonetheless, it is useful to become familiar with logdump for advanced troubleshooting.
    Good luck,
    -m

  • Can a HTML form send data to two servlets?

    I would like to know if an HTML Form can send data to two servlets, I guess I am askin is that can the parameters be passed to two ACTION attributes??

    Hmmmm, well I'm not sure if that is possible, but you could do something of the sort on the server side by chaining them.... the technieque is called Servlet Chaining
    Hope this helps
    Omer

  • How to add Jsp pages into existing portal (JDeveloper 9.0.4)

    I am a jsp developer. I have to add a jsp page into existing portal. I am new to portal. Could anyone help me how to develop jsp using portal classes like PortletRenderRequest,ProviderSession and others.

    Rigoberto, there should be no space between "-Xbootclasspath/p:" and the path "C:\oracle\infra\jdbc-10.1.0.4\ojdbc14.jar;C:\oracle\infra\jdbc-10.1.0.4\orai18n.jar"
    By the way, one can always take a look at the logs at
      $ORACLE_HOME/opmn/logs
    especially those files whose names start with OC4J~ if there is some wrong with oc4j processes. Those files are the default oc4j stout and sterr. If oc4j can not init, there should be some kind of error message in them.
    By the way, the following line may be deleted since no property file is specified.
      <data id="oc4j-options" value="-properties"/>
    Hope this helps.

  • How to refresh JSP page?

    Hi,
    How can I refresh my JSP Page?
    I am addind and deleting some mrecords with pressing button on my JSP page, but everytime I have to use browser's back button and hit refresh to see the updates.
    How can I just refresh it every time I update the page..
    Your help will be appreciated.
    Thanks

    int i = delete_Customer(delName);
                           System.out.println("i:"+i);
                           if (i==1)
    System.out.println("Sending response");                           
    response.sendRedirect("/abc/CustomerList.jsp");
    int delete_Customer(String delName) {
                   // TODO Auto-generated method stub
                   int i=0;          
                   Statement stmt = null;
                   Connection con = null;
                   try
                        System.out.println("In Try block for Deleting values");
                        Class driverClass = Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
                        Driver driver = (Driver) driverClass.newInstance();
                        DriverManager.registerDriver(driver);
                        con = DriverManager.getConnection("jdbc:db2:" + DB2Server, DB2UserID, DB2pass);
                        stmt = con.createStatement();
                        System.out.println(delName);
                        String query =
                             "DELETE FROM CUSTOMERNAME WHERE Customer_Name = '" +delName.trim()+ "'";
                             System.out.println("Values Deleted");
                              i = stmt.executeUpdate(query);
                             System.out.println("Nrows="+i);
                        stmt.close();
                        con.close();
                   catch(Exception e)
                        System.out.println("EXCEPTION : "+e.toString());
                        try
                             System.out.println("Severe error in DELETE, unable to continue");
                             if(stmt != null)
                                  stmt.close();
                             if(con != null)
                                  con.close();
                        catch(SQLException se)
                             System.out.println(se.toString());
                   System.out.println("i:"+i);
                   return i;
              }//delete method endsThis is my servlet code.
    It's not throwing any error,
    it's also going to my system log (sending response) but then it doesn't redirect it to the jsp page.
    Thanks

  • How to customize JSP page in iSupport

    Hi,
    I have worked on OA framework. But I have got a requirement to customize iSupport page in oracle apps. There is a Next button on page, I want to call one DB function by passing 2 parameters to this function. Get the result from that function and show the error message to user based in result of function.
    This page is JSP page. I got the JSP page name from URL in browser. I view the source of that page and found following statement..
    onclick="javascript:document.identifyproblem.JTFValidateFlag.value='Yes';*next*('identifyproblem', 'NEXTFROMIP'); return false " type="button">Next</button><img src="/OA_HTML/cabo/images/swan/t.gif" width="10" height="10"></td></tr></table>
    "next" function is available in one .js file which is imported in above file.
    function next(form, opcode)
    if (opcode =='NEXTFROMCI' || opcode =='NEXTFROMIP') {
    if (!checkContactPoint(form)) return;
    if (checkRequiredField(form)) {
    document.forms[form].IBU_CF_SR_OPCODE.value=opcode;
    document.forms[form].submit();
    else {
    return;
    If I want to change the functionality can I add my code in above "next" function?
    Or I will have to change something in controller file of that page??

    Hi Paraq,
    if you want to extend a seeded Oracle E-Business suite page you should use the personalization framework combined with a custom controller. Personalisations are done via the ebusiness suite user interface and involve no coding and allow you to intergate custom components into the app.
    Controller extensions are not recomended in E-Business suite however they are commonly implemented. You can personalise the page/region/table controller etc... to call your custom controller when they are invoked. See the OAF Personalization/Development guide for details on how to do this.
    One problem you will have here is that if you want to modify an existing controller you will need the source code which would probably mean getting an Oracle consultant or you could decompile the class files, failing that if you can bypass the existing controller by personalizing a different aspect of the page i.e. a region or table that doesnt already have a controller then you might get away with it.
    Keith

  • How does the attribute gets the data from R/3 field?

    Hi Experts,
    It could be silly Q.  IO has attributes x, y, z.......  When we map r/3 field to IO, and it is added to the cube and when we create a report, how does the attribute gets data?  I've been working in BW and suddenly I got confused.  Someone please provide me some info
    Thanks,
    Radha

    X,Y,Z being attributes of an info object A.
    When A gets loaded it will be loaded with X,Y,Z.
    If A is a cube and if you wish you can bring X,Y,Z also in the cube in one or more dimensions.
    If you keep X,Y,Z as vag attributes rather than in te cube as dimensions, then , the system will generate SIDs for them.
    Ravi Thothadri

  • How can a jsp page tell which Oracle Responsibility the user has selected?

    We have two responsibilities - Timecard Administrator and Timecard Viewer. Everything that they can access is the same, except for one particular jsp page which we want to present a slightly different view if the user's responsibility is Timecard Viewer (specifically, the edit link in the results page will be suppressed). Unfortunately in order to implement this, the jsp code needs to be able to distinguish which of those two responsibilities the user has selected. I have written jsp code to print all the environment variables and unfortunately the environment is essentially identical regardless of which of the two responsibilities the user selected.
    How do I pass in the active responsibility to that page/environment in a way that can be tested by the jsp code?
    Thank you,
    Graham Toal <[email protected]>

    Yes, I tried something like this (shortened to the basics for this post):
    <pre>
    sqlQuery="select responsibility_name from fnd_responsibility_vl where responsibility_id = FND_GLOBAL.RESP_ID";
    stmt=con.createStatement();
    rs=stmt.executeQuery(sqlQuery);
    int field_count=rs.getMetaData().getColumnCount();
    while (rs.next()) {
    for (int i=0; i<field_count; i++) {
    logger.write("Responsibility: "+rs.getObject(i+1),"JSP",objName,0,-1,1001);
    </pre>
    However it did not print any results at all.
    I'm trying a different approach at the moment - I've cloned the menus from the Administrator responsibility to the new Viewer responsibility, and have altered the top-level menu so that I can insert a new variable into the process state myself; that way by the time the user navigates to the changed page, there should be a variable there that can be tested.
    Unfortunately the top-level menu isn't just a simple menu, it's a piece of code that issues an HTML redirect depending on the parameter passed in - which is set in the Oracle function screen for the function attached to that menu.
    (was something like utpa_top_menu.jsp?ADMIN and I changed it to utpa_top_menu.jsp?VIEWER, with appropriate tests for the new module name:
    <tt>
    else if ("VIEWER".equals(moduleName))
    url = "/utpa/jsp/admin_reports-viewer.jsp";
    </tt>
    In admin_reports-viewer.jsp I've added <tt>session.putValue("REPVIEWER","y");</tt> and in the actual target main page I have:
    <pre>
    if (session.getValue("REPVIEWER") == "y") {
    // viewer
    out.println("<CENTER><B>You are using the Timecard Viewer responsibility</B></CENTER><BR>");
    } else {
    </pre>
    And although the URL bar at the top of the screen is displaying the correct (redirected) URL, the page that is displayed is blank. Completely empty. 0 bytes. The file is present on the filing system; has content; has the correct ownership and permissions; I've reloaded apache, even had the systems guys reboot completely. I'm at a loss :-/
    Graham

  • How does apple Configurator Backup App data? Or does it at all?

    Hello,
    I use Apple Configurator at two schools. All of the iPads that the schools own are supervised via Apple Configurator.
    How does the backup feature work in Apple Configurator? I know it backs up folders and photos and videos. But does it backup app data? And how?
    I understand that apps themselves are not backed up. But if an iPad is completely wiped / restored via apple configurator / apps are put back on / then backup is restored.... when does the app data get re-applied (if it does at all?)
    Mac OS 10.9.4
    Apple Configurator Version 1.5 (424)
    I know iTunes can backup and restore app data. My question is does Apple Configurator do it? And how / what is the best way?
    Thank you.

    When you boot yoru iMac, if you hold down the option key, at the boot meny, do you have an option for "Network" booting  If so, then your machine didn't come with an install disc, it allows for internet restore form Apple servers (although it will need to perform the 4.7GB download if you use it).
    If you run the Boot Camp Assistant, you should be presented with an option to download the windows support files from Apple servers.  For machines which didn't come with install/restore discs, this is the way to get the files you need.

Maybe you are looking for