Need help using JSTL on JSP pages

Kindly let me know what should be done in order to get the following JSP to work:
<jsp:useBean id="subtypes" class="com.jsptest.Code.Subtypes"/>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
               <td width="15%" valign="top" align="center" bgcolor="#009999"><table width="149" border="0" cellpadding="0" cellspacing="0" bgcolor="#009999">
                        <tr>
                             <th scope="row"> </th>
                           </tr>
                           <c:forEach var="val" items="${subtypes.allSubtypesDescriptions[0]}" varStatus="status">
                           <tr>
                                <th width="117" scope="row"><a href="/jspteste/testpage3.jsp?subtypeDesc=<c:out value="${val}"/>>"><font face="Courier New, Courier, monospace"><c:out value="${val}"/></font></a></th>
                         </tr>
                         <tr>
                              <th>----</th>
                         </tr>
                         </c:forEach>
                           <tr>
                             <th scope="row"> </th>
                           </tr>
                    </table>
          </td>
</table>I keeps giving me the following error:
exception
org.apache.jasper.JasperException: org.apache.jasper.el.JspPropertyNotFoundException: /testjstl.jsp(32,7) '${subtypes.allSubtypesDescriptions[0]}' Property 'allSubtypesDescriptions' not found on type com.jsptest.Code.Subtypes
     org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.apache.jasper.el.JspPropertyNotFoundException: /testjstl.jsp(32,7) '${subtypes.allSubtypesDescriptions[0]}' Property 'allSubtypesDescriptions' not found on type com.jsptest.Code.Subtypes
     org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:104)
     org.apache.jsp.testjstl_jsp._jspx_meth_c_005fforEach_005f0(testjstl_jsp.java:199)
     org.apache.jsp.testjstl_jsp._jspService(testjstl_jsp.java:119)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
The Subtypes class is above:
import com.jsptest.dbAccess.DbConnection;
public class Subtypes extends DbConnection{
     private char[] categoryCode;
     private char[] subtypeCode;
     private String subtypeDescription;
     private String[][] allSubtypesDescriptions;
     public void setCategoryCode(char[] categoryCode){
          this.categoryCode  = categoryCode;
     public void setSubtypeCode(char[] subtypeCode){
          this.subtypeCode = subtypeCode;
     public void setSubtypeDescription(String subtypeDescription){
          this.subtypeDescription = subtypeDescription;
     public char[] getSubtypeCode(){
          String sqlStmt;
          sqlStmt = "SELECT category_subtype FROM category_subtypes WHERE subtype_description =\'" + subtypeDescription + "\'";
          subtypeCode = pullSingleStringRecord(sqlStmt).toCharArray();
          return subtypeCode;
     public char[] getCategoryCode(){
          String sqlStmt;
          sqlStmt = "SELECT category_code FROM category_subtypes WHERE subtype_description = \'" + subtypeDescription + "\'";
          categoryCode =  pullSingleStringRecord(sqlStmt).toCharArray();
          return categoryCode;
     public String[][] getAllSubtypeDescriptions(){
          String sqlStmt;
          sqlStmt = "SELECT subtype_description FROM category_subtypes ORDER BY subtype_description";
          allSubtypesDescriptions = pullAllRecordsAsString(sqlStmt);
          return allSubtypesDescriptions;
}Appreciate your inputs.
T. San.

You are calling ${subtypes.allSubtypesDescriptions[0]} and not ${subtypes.allSubtypeDescriptions[0]}
note the difference in your method name and your variable name.
m

Similar Messages

  • Need help in writing a .jsp page

    Hi Guys,
    I am new to JSP. My requirement is " I have a link on my webpage. When the user clicks that link, a HTML page is displayed which has parameters to be entered (for ex: from_date , to_date). When the user clicks the submit button, a jsp page should be displayed in which a query is run to display the output. For example, the user enters the from_date and to_date parameter values to know the employees employed within those dates in their company. The query is "select empname,empno,sal,dept,comm from emp where employed_date between from_date and to_date" . The following should run and display in the jsp page.
    How can i write a .jsp to extract the parameters that are entered in the HTML form in to a .jsp and run the query with those parameters to display the output. Help needed in making me write this .jsp for this query.
    Help Aprreciated.
    Thanks

    Hm, your requirements sound like homework assignment from classroom. If so, is itn't better that you find the answer youself? There are plenty of very relevant references for how to use jsp to handle html forms or talk to a rdbms through a jdbc connection. For example, for jsp and html forms, you can google "jsp html forms"; for jsp and sql query, search for "jsp jdbc".
    Tell me if this is not helpful.

  • Need help on sharing a jsp page between clients?

    Hi,
    Let me explain this:
    In my jsp application I have two jsp pages that work as a find dialog like applet find dialog.One of those shows the columns from rowset(which user can enter the criteria ) and the other gets the values from first one, makes the sql query and execute the query against the rowset and retrieve the data. There is no pure servlet, both are jsp pages.
    This application is deployed on AS9i-oc4j.
    Problem is : When this find dialog is working for a client. The other client could not load this find dialog until the work for the first one be done. I mean only one client could load and fire the sql statement via this jsp pages(find dialog) at the same time. Which is not acceptable in web applications. Seems only one instance of these pages created by oc4j . if I am right on this then
    Question is : Why oc4j doesn’t create the number of instances based on the number of clients that call these pages? Did I miss something. Or any property in Application module need to be set?
    I would appreciate to share me your idea on this.
    Thanks.

    In my primary mind maybe the bottleneck is where the execution of rowset happens. Since that portion of code takes time to retrieve data for business components. If this is the case then Is this problem goes away if I define a thread for this portion of code?
    Thanks in advance for any idea.

  • Some dummies need help in master detail jsp page

    We don't know how to use data control to generate a jsp master detail page in case of many-to-many relationships. We didn't find any info about this and our testcase never display the data of the last iterator.
    We have
    a collection that contains department object.
    a collection that contains the relationship between department and employee (the many-to-many relationship)
    an object that represent the employee
    The structure is correct in the data control.
    We are able the create our page for both first and second collection but it is not possible to display the detail of the corresponding employee in the detail table. When the table is generated from this level no data is displayed.
    Is it somewhere described how to solve such problem ?
    Does somebody know how to do ?

    Hm, your requirements sound like homework assignment from classroom. If so, is itn't better that you find the answer youself? There are plenty of very relevant references for how to use jsp to handle html forms or talk to a rdbms through a jdbc connection. For example, for jsp and html forms, you can google "jsp html forms"; for jsp and sql query, search for "jsp jdbc".
    Tell me if this is not helpful.

  • Need help accessing the router web page.  I have been tol...

    Need help accessing the router web page.  I have been told my router is acting like a switch and the IP address is not in the proper range.  I have tried reseting the router (hold for 30 sec and unplug for 5 mins).  Didn't work.
    thanks

    What router are you using?  Almost all Linksys routers use 192.168.1.1 as the default local IP address, but there is at least one that uses 192.168.16.1 , namely the WTR54GS  (not the WRT54GS).
    You need to try again to reset the router to factory defaults.
    To reset your router to factory defaults, use the following procedure:
    1) Power down all computers, the router, and the modem, and unplug them from the wall.
    2) Disconnect all wires from the router.
    3) Power up the router and allow it to fully boot (1-2 minutes).
    4) Press and hold the reset button for 30 seconds, then release it, then let the router reset and reboot (2-3 minutes).
    5) Power down the router.
    6) Connect one computer by wire to port 1 on the router (NOT to the internet port).
    7) Power up the router and allow it to fully boot (1-2 minutes).
    8) Power up the computer (if the computer has a wireless card, make sure it is off).
    9) Try to ping the router. To do this, click the "Start" button > All Programs > Accessories > Command Prompt. A black DOS box will appear. Enter the following: "ping 192.168.1.1" (no quotes), and hit the Enter key. You will see 3 or 4 lines that start either with "Reply from ... " or "Request timed out." If you see "Reply from ...", your computer has found your router.
    10) Open your browser and point it to 192.168.1.1. This will take you to your router's login page. Leave the user name blank (note: a few Linksys routers have a default user name of "admin" (with no quotes)), and in the password field, enter "admin" (with no quotes). This will take you to your router setup page. Note the version number of your firmware (usually listed near upper right corner of screen). Exit your browser.
    If you get this far without problems, try the setup disk (or setup the router manually, if you prefer), and see if you can get your router setup and working.
    If you cannot get "Reply from ..." in step 9 above, your router is dead.
    If you get a reply in step 9, but cannot complete step 10, then either your router is dead or the firmware is corrupt. In this case, use the Linksys tftp.exe program to try to reload your router with the latest firmware. After reloading the firmware, repeat the above procedure starting with step 1.
    If you need additional help, please state your ISP, the make and model of your modem, your router's firmware version, and the results of steps 9 and 10. Also, if you get any error messages, copy them exactly and report back.
    Please let me know how things turn out for you.
    Message Edited by toomanydonuts on 01-21-2008 04:40 AM

  • I need helping using iAds in my application.

    I need helping using iAds in my application. I currently am not using any storyboards. I am using Sprite builder for my UI.
    I attatched an image ot show all the different file name I have.
    Everyone is being used & they all work fully.
    The "iAdViewController.h & .m" files are just example codes I looked up and was messing with so that my iAd can work.

    I wouldn't even be able to use the Mathscript node in an executable? 
    What I am trying to do is make a user configurable data stream. 
    They tell me how many bytes are in the stream and what parameters they
    want to be put in to it.  Currently I have to make vi's that are
    called dynamicaly to make the parameters.   Then recompile
    the code and send it to them.  This is somewhat of how the config
    file is set up so I know how to make the data.
    Data_Type  foo
    Bytes 30
    parameter_name        
    function           
       byte#          format
    sync              
    foo_sync            
    29               int
    time                              
    foo_time             
    1,2,3,4       double
    If I can't use MathScript to allow the user to make there own functions
    is there another way that I might be able to do this so I do not have
    to recompile the code atleast?  Were I might just be able to make
    the new function and send that to them.
    Any Idea would be great.

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • HT5622 i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading

    i need help using the icloud it is not making any since to me can some one call me and help me with it please don't try to help me through email i need to talk and listen i don't understand instruction by reading.
    <Phone Number Edited by Host>

    You aren't addressing anyone from Apple here.  This is a user forum.
    You might want to call a neaby Apple store to see if they have a free class you could attend.

  • Need help using dbms_scheduler to submit an immediate job on the database

    Hi. I need help using dbms_scheduler to submit an immediate job on the database. Essentially I want to issue a one-time call to an Oracle Stored Procedure - this procedure will then send an email. I've never used dbms_scheduler before, but here's what I have so far.
    So my Program is a stored database procedure named 'TTMS.dropperVacationConflict_Notify', but my problem is that I need to pass 3 parameter values to this job each time I run it. This is what I can't figure out. The procedure expects an 'Id' as number(5), begin_dt as a date, and end_dt as a date.
    How do I pass these values when I run my job? Can anyone help?
    begin
        dbms_scheduler.create_program(program_name=> 'PROG_DROPVACCONFLICTS_NOTIFY',
         program_type=> 'STORED_PROCEDURE',
         program_action=> 'TTMS.dropperVacationConflict_Notify',
         number_of_arguments => 3,
         enabled=>true,
         comments=> 'Procedure to notify PCM of a Dropper Vacation Conflict. Pass in Dropper Id, Begin_dt, and End_dt');
    end;
    begin
        dbms_scheduler.create_schedule
        (schedule_name=> 'INTERVAL_EVERY5_MINUTES',
         start_date=> trunc(sysdate)+18/24,
         repeat_interval => 'freq=MINUTELY;interval=5',
         end_date => null
         comments=> 'Runtime: Every day all 5 minutes, forever'
    end;
    begin
        dbms_scheduler.create_job
        (job_name => 'JOB_DROPVACCONFLICTS_NOTIFY',
         program_name => 'PROG_DROPVACCONFLICTS_NOTIFY',
         schedule_name => 'INTERVAL_EVERY5_MINUTES',
         enabled => true,
         auto_drop => true,
         comments => 'Job to notify PCM of Dropper Vacation Conflicts'
    end;
    /And I use this to execute the job as needed...
    begin
        dbms_scheduler.run_job('JOB_DROPVACCONFLICTS_NOTIFY',true);
    end;
    /

    Duplicate Post
    Need help using dbms_scheduler to submit an immediate job on the database

  • Help needed..Unable to acess JSP page..

              Hai!
              I started Admin Server and Managed Server. When i tried to acess jsp page that
              is deployed in the default webapplication of Managed server , In the log file
              of Managed Server It is adding AdminServer to the Client list and application
              hangs(Nothing will be displayed in browser..Neither error message nor Desired
              page ). I am wondering why this is happening as Admin server is neither participating
              in a cluster nor is the Target for default webapplication of Managed server .
              Any help?
              TIA
              Rgds
              Manohar
              

    First check whether a simple jsp file with just "Hello World" is running or not.
    If it is running than my guess is that the library you are importing in JSP is not getting imported.
    This could be because your library is not in your classpath when you are deploying the application, check that in you ear file, WEB-INF/lib folder for this.
    Basically you will try several things out to get to source of error.
    all the best.

  • Justifications needed for using tags in JSP, Please reply

    Hi forum
    My question is to those java people who have also done JSP. I m sound in java server side (servlet programming), now I have asked by my project manager to do server side programming in JSP using tagLibraries (as these are used by those ppl who didnt have much java knowledge). I have worked inserver side java, then my question is y should I start working on tags,
    On the other hand I can do all the work in java embedding in JSP (on some extent, seperated by diffrent helper/util classes to reduce the thickness of JSP page).
    so I want to ask u ppl that should a java programmer needs to use tag libraries to code a JSP page, however he can code it in java directly.
    I will feal great pleasure if u will write ur opinions and help me to ease my life.
    thanx in advance
    Best Regards
    Tahir

    You should use tag libraries whenever you can because:
    1) They increase code re-useability. You can insert the same tag in many pages using just a few lines to do complex tasks, as opposed to writing a lot of scriptlet code in each JSP.
    2) Enhance your ability to seperate logic from display. Everything in your tags is logic. Everything in your JSP is display - with the tags bridging the logic to the display.
    3) Make the JSPs cleaner and easier to maintain. They read easier with tags than with a lot of scriptlets. Non-java people can be used to update the look and feel of the web page, or to debug the HTML later on, relieving the Java programmers for the tag work, or other jobs more suited to them.
    4) Your boss said to do tags, so do tags.

  • Unable to use jstl in jsp

    Already I read out the discussion about this topic. But still I face the same problem. I have already put the jstl and standard jar files in the WEB-INF\lib directory and modified the web.xml file adding the following lines.
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/lib/fmt.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/fmt-rt</taglib-uri>
    <taglib-location>/WEB-INF/lib/fmt-rt.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/lib/c.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core-rt</taglib-uri>
    <taglib-location>/WEB-INF/lib/c-rt.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/sql</taglib-uri>
    <taglib-location>/WEB-INF/lib/sql.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/sql-rt</taglib-uri>
    <taglib-location>/WEB-INF/lib/sql-rt.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/x</taglib-uri>
    <taglib-location>/WEB-INF/lib/x.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>http://java.sun.com/jstl/x-rt</taglib-uri>
    <taglib-location>/WEB-INF/lib/x-rt.tld</taglib-location>
    </taglib>
    In jsp page I have written the following lines.
    <%@taglib prefix="c" uri="http://java.sun.com/jstl/core-rt"%>
    <%@taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt"%>
    I have got the following error :
    org.apache.jasper.JasperException: File "/WEB-INF/lib/c-rt.tld" not found
    please help

    Just in case someone is still having problems, the better solution is not to have these entries in web.xml at all.
    To run JSTL, all you need are the two jar files (standard.jar, jstl.jar) in the WEB-INF/lib directory,
    - NO entries in web.xml
    - NO tld files
    - no problems!!!
    You then use the "standard" uri to import the taglibraries into your jsp pages.
    JSTL1.0 - <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
    JSTL1.1 - <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    Use JSTL1.0 in Servlet2.3/JSP1.2 containers (Tomcat 4)
    Use JSTL1.1 in anything more than that.

  • URGENT: Need help reading URL of current page

    Hello kind people!
    I need help, and its very simple:
    How do i read the URL of a web page?
    For example, the URL of this page is:
    http://forums.sun.com/thread.jspa?threadID=5327796
    So how can i be able to read in this URL in my java program?
    thanks SO MUCH
    P.S. I HAVE searched the java docs and everything, the closest thing i found was request.getRequestURL().? but i have no idea how to use it. you have NO IDEA how appreciative i would be if you could simply show me exactly how to read in the URL of a given page.
    thanks SO MUCH
    Edited by: homegrownpeas on Aug 31, 2008 5:19 PM

    Going by what I understand here is a simple version of how you can read data from over HTTP.
    This expects the "page" to be text (hence an InputStreamReader instead of an InputStream.)
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.HashMap;
    * GPLv2.
    * @author karlm816
    public class HomeGrownPeas {
          * @param args
         public static void main(String[] args) {
              HashMap<String, String> params = new HashMap<String, String>();
              params.put("threadID", "5327796");
              System.out.println(loadHttpPage("http://forums.sun.com/thread.jspa", params));     
         public static String loadHttpPage(String sUrl, HashMap<String, String> params) {
              // Build the HTTP request string
              StringBuilder sb = new StringBuilder();
              if (params != null) {
                   for (String key : params.keySet()) {
                        if (sb.length() > 0) {
                             sb.append("&");
                        sb.append(key);
                        sb.append("=");
                        sb.append(params.get(key));
              System.out.println("params: " + sb.toString());
              try {
                   URL url = new URL(sUrl);
                   URLConnection connection = url.openConnection();
                   connection.setDoOutput(true);
                   connection.setRequestProperty("Content-Length", "" + sb.length());
                   connection.setUseCaches(false);
                   if (connection instanceof HttpURLConnection) {
                        HttpURLConnection conn = (HttpURLConnection) connection;
                        conn.setRequestMethod("POST");
                   OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream());
                   osw.write(sb.toString());
                   osw.close();
                   // Now use sb to hold the resutls from the request
                   sb = new StringBuilder();
                   BufferedReader in = new BufferedReader(
                         new InputStreamReader(
                         connection.getInputStream()));
                   String s;
                   while ((s = in.readLine()) != null) {
                        sb.append(s);
                        // To make it more "human readable"
                        sb.append("\n");
                   in.close();
             } catch (IOException e) {
                  e.printStackTrace();
                  return null;
            return sb.toString();
    }

  • XML transformation using XSLT in JSP page

    Hi,
    Please help, I'm getting this error when I try to render my xml file using an xsl style sheet in my JSP page. Am I missing a JAR? Thanks
    Error 500: org/apache/xalan/xslt/XSLTInputSource
    Here's xsl file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
    <xsl:template match="/">
      <html>
      <body>
      <h2>My CD Collection</h2>
        <table border="1">
          <tr>
            <th align="left">Title</th>
            <th align="left">Artist</th>
          </tr>
          <xsl:for-each select="catalog/cd">
          <tr>
            <td><xsl:value-of select="title"/></td>
            <td><xsl:value-of select="artist"/></td>
          </tr>
          </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>
    And here's my JSP page
    <%@taglib uri="http://jakarta.apache.org/taglibs/xsl-1.0" prefix="xsl"%>
    <html>
    <head><title>Phone Book</title></head>
    <body>
    <xsl:apply xml="/xml/book.xml" xsl="/xml/book.xsl" />
    </body>
    </html>
    And here's my xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- Edited with XML Spy v4.2 -->
    <catalog>
         <cd>
              <title>Empire Burlesque</title>
              <artist>Bob Dylan</artist>
              <country>USA</country>
              <company>Columbia</company>
              <price>10.90</price>
              <year>1985</year>
         </cd>
         <cd>
              <title>Hide your heart</title>
              <artist>Bonnie Tyler</artist>
              <country>UK</country>
              <company>CBS Records</company>
              <price>9.90</price>
              <year>1988</year>
         </cd>
    </catalog>

    i would think the browser should be able do the transformation itself, rather than having to do this transformation on the server.
    If you want to do this on the server, you can always try adding xalan.jar, xml-apis.jar and xercesImpl.jar to your server's lib directory, downloaded from
    apache.org

  • How to use class in JSP page ? In java works in JSP not...

    Hello developers,
    I need check if URL exists.. i use this code in java.. it works fine..
    import java.net.*;
    import java.io.*;
    public class Check {
    public static void main(String s[]) {
        System.out.println(exists("http://www.google.com"));
        System.out.println(exists("http://www.thisURLdoesntexis.com"));
    static boolean exists(String URLName){
      try {
        HttpURLConnection.setFollowRedirects(false);
        // note : you may also need
        //        HttpURLConnection.setInstanceFollowRedirects(false)
        HttpURLConnection con =
           (HttpURLConnection) new URL(URLName).openConnection();
        con.setRequestMethod("HEAD");
        return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
      catch (Exception e) {
           e.printStackTrace();
           return false;
    }in java all works fine.. it shows
    TRUE
    FALSE
    but i have no idea how can i implement this java code to my check.jsp page..
    i tried something like this..
    <%@ page import="java.io.*" %>
    <%@ page import ="java.net.*" %>
    <BODY>
    <%
    static boolean exists(String URLName){
      try {
        HttpURLConnection.setFollowRedirects(false);
        // note : you may also need
        //        HttpURLConnection.setInstanceFollowRedirects(false)
        HttpURLConnection con =
           (HttpURLConnection) new URL(URLName).openConnection();
        con.setRequestMethod("HEAD");
        return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
      catch (Exception e) {
           e.printStackTrace();
           return false;
    String a="http://www.google.com";
    %>
    <%= exists(a)%>and i want to see in my jsp page the result.. it means that JSP page shows
    TRUE
    Thanks in advance,

    Hi there,
    One solution is to use JavaBeans and call the methods for the JavaBean from the JSP page.
    Suppose you have a JavaBean called TestConnectionBean as follows:
    package test22;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.IOException;
      Set the testUrl before checking if connection exists.
    public class TestConnectionBean {
        String testUrl;
        boolean connectionExists;
        public TestConnectionBean() {
        public String getTestUrl() {
            return testUrl;
        public void setTestUrl(String testUrl) {
            this.testUrl = testUrl;
        public boolean getConnectionExists() throws IOException, MalformedURLException {
            HttpURLConnection.setFollowRedirects(false);
            // note : you may also need
            //        HttpURLConnection.setInstanceFollowRedirects(false)
            HttpURLConnection con = null;
            con = (HttpURLConnection) new URL(this.testUrl).openConnection();
            con.setRequestMethod("HEAD");
            return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
        public void setConnectionExists(boolean connectionExists) {
            this.connectionExists = connectionExists;
    }Then you can create a JSP page like this:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
      <head><title></title></head>
      <body>
      <jsp:useBean id="testConnectionBean" class="test22.TestConnectionBean"/>
      <jsp:setProperty name="testConnectionBean" property="testUrl" value="http://www.google.com" />
      <br/><br/>
      Does the connection exist for http://www.google.com : <jsp:getProperty name="testConnectionBean" property="connectionExists"/>
      <br/><br/>
      <jsp:setProperty name="testConnectionBean" property="testUrl" value="http://www.thisURLdoesntexis.com" />
      <br/><br/>
      <%-- The following will give an exception : java.net.UnknownHostException: www.thisURLdoesntexis.com since the URL doesn't exist. 
      --%>
      <%--
      Does the connection exist for http://www.thisURLdoesntexis.com : <jsp:getProperty name="testConnectionBean" property="connectionExists"/>
      --%>
      </body>
    </html>The output you see looks like:
    Does the connection exist for http://www.google.com : true
    I think it is better to handle the exceptions in the JavaBean itself, so now yyou can change the method signature of getConnectionExists , remove all exceptions from method signature but handle them with a try/catch inside the method itself.

Maybe you are looking for

  • Exception - meaningless exception message

    Guys please help Whats with this code import java.util.*; public class ExcInMap {         static Map m;         public static void main(String args[])throws Exception{                 m = new HashMap();               m.put("st",new FancyException());

  • Garbage charaters in Thai PDF bookmarks

    Hi, Does anyone have any ideas why Thai bookmarks cannot be displayed correctly in Acrobat (4.0 and above) after generated from FrameMaker 7.x? I have tried both system font - FreesiaUPC and 3rd party font, however both can't resolve the garbage char

  • Deployement in biztalk 2013

    Hi all, I am migrating biztalk server 2010 to 2013. Using visual studio conversion wizard i have converted all applications into 2012. Can any one please help me out how to deploy the application in biztalk 2013 as i am new to it. and what would be t

  • How to stop apple tv automatic updates

    Hi, How would it be possible to turn off automatic updates on an apple TV 3? I am working with several in a school enviroment connected to our projectors. And for security reasons they are put above the cieling so they are out of sight with cabling g

  • Reset ASM

    Hey folks Is there a way to reset the ASM Instance. I mean, where does ASM stores the information e.g. the diskgroup name etc..? there is nowhere an controlfile or something similar. the reason is: I can't drop my diskgroup because i can't mount them