Simple linkchecker in jsp

Thanks in advance,
Hello,
in order to build a simple jsp, that enables to check links, i tried to modificate the class "GetURLInfo". The idea is simply reading out the http-header, and print out the Response Message and Code.
Unfortunately i dont know how to make this class able to take the url as a String-Object? Can anyone help me out, please?
Greetings from Hamburg,
Bj�rn
import java.net.*;
import java.io.*;
import java.util.Date;
public class GetURLInfo {
public static void printinfo(URL url) throws IOException {
URLConnection c = url.openConnection(); // Get URLConnection from the URL
c.connect(); // Open a connection to the URL
// Display some information about the URL contents
System.out.println(" Content Type: " + c.getContentType());
System.out.println(" Content Encoding: " + c.getContentEncoding());
System.out.println(" Content Length: " + c.getContentLength());
System.out.println(" Date: " + new Date(c.getDate()));
System.out.println(" Last Modified: " + new Date(c.getLastModified()));
System.out.println(" Expiration: " + new Date(c.getExpiration()));
// If it is an HTTP connection, display some additional information.
if (c instanceof HttpURLConnection) {
HttpURLConnection h = (HttpURLConnection) c;
System.out.println(" Request Method: " + h.getRequestMethod());
System.out.println(" Response Message: " + h.getResponseMessage());
System.out.println(" Response Code: " + h.getResponseCode());
/** Create a URL object, call printinfo() to display information about it. */
public static void main(String[] args) {
try { printinfo(new URL(args[0])); }
catch (Exception e) {
System.err.println(e);
System.err.println("Usage: java GetURLInfo <url>");

I'm not sure if I got you right. Do you want to have another signature for printinfo()?
The solution then is:
public static void printinfo(String urlString) throws IOException, MalformedURLException {
  URL url = new URL(urlString);
}

Similar Messages

  • Simple and Free JSP Editor Plugin for Eclipse

    Can anyone direct me a Simple and Free JSP Editor Plugin for Eclipse ? Thanks

    You can just create JSP files with "Eclipse for Java EE".
    What do you expect of the plugin then?

  • How to show simple chinese in jsp

    when I use simple chinese in jsp,in the portlet all the char convert into B>B-C&#147;B*B;C.B6B/,but in the servlet,all the simple chinese char it right,I have set the conentType = "text/html;gb2312",but the problem is still.
    somebody can help me!
    thanks!

    You have to set the content type on your response firts.
    eg; response.setContentType("image/gif");

  • Using simple functions in JSP

    Hi to all,
    I would to use simple functions in my jsp page.
    I 've created the function with the tags <%! ... %>
    My problem is that i don't succed to call there from the page.
    How i can to do ?
    I've tried also with java beans but i'm not very clever with there also so i don't can to go forward !!!
    Please help me. thanks

    Hi, a new problem rises now.
    the problem is into the method ctr_data().
    Under i put the jsp code and the error:
    Anyone can see where is the error please?
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import= "java.sql.*,  java.lang.*" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
      <title>Progetto Sofia - Registrazione utente</title>
    </head>
    <%!
    public boolean ctr_lunghezza(String s1){
        if (s1.length() == 0) return false;
        return true;
    %>
    <%!
    public boolean isLeapYear(int year) {
           if (year%400 == 0)  return true;
           if ((year%4 == 0) && (year%100 != 0))return true;
           return false;
    %>
    <%!
    public boolean ctr_data (String gg, String mm, String aa){
        int anno = Integer.valueOf(aa).intValue();
        int mese = Integer.valueOf(mm).intValue();
        int giorno = Integer.valueOf(gg).intValue();
        if ((gg.length() == 0) || (mm.length() == 0) || (aa.length() == 0))
            return false;
        if ((anno < 1905) || (anno > 2005))
            return false;
        if (mese == 2){
            if (isLeapYear(anno)){
                if (giorno > 29) return false;
            }else{
                if (giorno > 28) return false;
        if ((mese == 11) || (mese == 4) || (mese == 6) || (mese == 9)){
            if (giorno == 31) return false;
        return true;
    %>
    <%
    int flag = 0;
    String risposta = "";
    String temp ="";
    temp = (request.getParameter("nome_utente")!=null)?request.getParameter("nome_utente") :"";
    if (ctr_lunghezza (temp) == false){
       risposta = risposta.concat("Attenzione --- Riempire il campo: Nome\n");
       flag++;
    temp = (request.getParameter("cognome_utente")!=null)?request.getParameter("cognome_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Cognome\n");
        flag++;
    String gg1 = (request.getParameter("giorno_n_utente")!=null)?request.getParameter("giorno_n_utente"):"0";
    String mm1 = (request.getParameter("mese_n_utente")!=null)?request.getParameter("mese_n_utente"):"0";
    String aa1 = (request.getParameter("anno_n_utente")!=null)?request.getParameter("anno_n_utente"):"0";
    if (!ctr_data(gg1, mm1, aa1)){
        risposta = risposta.concat("Attenzione --- Data di nascita non corretta\n");
        flag++;
    temp = (request.getParameter("luogo_n_utente")!=null)?request.getParameter("luogo_n_utente"):"";
    if (!ctr_lunghezza (temp)){
        risposta = risposta.concat("Attenzione --- Riempire il campo: Luogo di nascita\n");
        flag++;
    temp = (request.getParameter("res_utente")!=null)?request.getParameter("res_utente"):" ";
    if (temp == "Seleziona"){
        risposta = risposta.concat("Attenzione --- Selezionare il Comune di Residenza\n");
        flag++;
    temp = (request.getParameter("ind_utente")!=null)?request.getParameter("ind_utente"):" ";
    if (!ctr_lunghezza(temp)){ 
        risposta = risposta.concat("Attenzione --- Riempire il campo Indirizzo\n");
        flag++;
    %>and this is the error msg:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: For input string: ""
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NumberFormatException: For input string: ""
         java.lang.NumberFormatException.forInputString(Unknown Source)
         java.lang.Integer.parseInt(Unknown Source)
         java.lang.Integer.valueOf(Unknown Source)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp.ctr_data(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:27)
         org.apache.jsp.progetto.w2.web.Reg_005futente_jsp._jspService(org.apache.jsp.progetto.w2.web.Reg_005futente_jsp:122)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • How deploying a simple report as .jsp

    Hi,
    i have read the last days many document, and messages on this board.
    But I could not find answers.
    My problem is:
    I create a simple report with reportbuilder and save this to mysample.jsp.
    I copy this file to Oracle Application Server j2ee\OC4J_BI_Forms\applications\reports\web\.
    When i call the report from web http://myservername/reports/mysample.jsp?userid=.
    The server return follow error:
    Anforderungs-URI:/reports/JSP_Demo.jsp
    Exception:
    java.io.FileNotFoundException
    Oracle Application Server Forms and Reports Services 10g (9.0.4.0.1) for Microsoft Windows with Patch Set 2 (9.0.4.2.0)

    Are you sure you're copting the Reports to the right place. There's a difference running Developer Suite and Application Server. Check documentation and/or Metalink. Also, I would place this question next time in the Reports forum, not in the Application Server (General) forum:
    Reports
    Martin

  • Simple question from jsp newbie

    Hi friends,
    I am learning jsp now. Reading documents and implementing simple applications. But i want to ask a question that is opposite to my logic.
    Now, i am a textfield control on jsp as textField1. I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.
    Thanks.

    technologyMan wrote:
    I am learning jsp now. You´re actually at the JSF forum here.
    Now, i am a textfield control on jsp as textField1. You are? Really?
    I have created this control from Palette. in java code i am writing "textbox1." but there is no action, no intellisense while pressing ctrl + space.
    How the control is accessing from java code? Maybe my logic with visual studio .net. but i want to learn jsp logic.Uh, just write code accordingly? You can use h:commandButton/h:commandLink for that.
    Anyway, if you want to start with JSF, I can recommend you the following sources:
    Java EE tutorial part II, JSF starts at chapter 10: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Good kickoff tutorial: [http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html]
    The JSF taglib documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/]
    The JSF API documentation: [http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/overview-summary.html]

  • How to call a simple bean from jsp in weblgic 6.1

    Hi All,
    Can any one help me , my problem is i have a jsp that is calling a simple bean method for displaying a message .
    When im trying to call the beans methods it conntinusly giving me error unable to resolve the Beans' name
    my jsp content is:
    <%@ page language="java" import="com.Arvind*"%>
    <jsp:useBean id="mybean" scope="session" class="com.Arvind" />
    <%
         out.println("Hello"+mybean.callMe());
    %>
    beans is :-
    package com;
    public class Arvind
         private String st ="This Is Me??";
         public String callMe(){
              System.out.println("Hello World!");
              return st;
         public static void main(String[] args)
              System.out.println("Hello World!");
    i have tried it a lot but all time it fails resolve the class name itself ??
    can anyone please help me urgently
    thanks in advance
    rgds
    Birendar

    It might compile perfectly well, but the message suggests that you didn't deploy it properly. The class loader can't find it.
    That .class file should appear with its package directory structure under the WEB-INF/classes directory or in a JAR in your WEB-INF/lib directory in some WAR file. Does it?

  • Simple deploy of JSP with Bus.Cmps to OC4J

    Jdeveloper Ver. 10.1.2
    OC4J version 10.1.2
    I want to deploy a simple app from Jdeveloper to a standalone OC4J instance. I contains a simple table busines component and a UIX table component. I want it to be a public web page, not security/authentication/authorization needed. I deploy the ear file (which includes the war file needed for the jsp), the deployment works and gives me the url to acces the page. On a previous version of OC4j/jedevloper(9.0.3), this always worked without a problem. Now I get a 403 forbidden error when I go to the root location specified in the http-web-site.xml for this application.
    http://<server>:<port>/<root location for deployed application>
    I cannot find any logging to determine where the error is. Obvisouly there is some new security feature that has been added in this version of OC4j. What do I need to do to deploy a public applcation to this version of OC4j?

    Don't go to the root - go to a specific JSP or Struts action.
    Look at the URL that you get when you run inside JDeveloper to find out which page you need to get to.

  • Error when run a simple sample using jsp tag

    When i run a jsp using jsp tag, the tomcat gave me the following information:
    Resolve entity failed-//Sun Microsystems,Inc.//DTD JSP Tag Library 1.2//EN http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd
    My tld file is:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>sample</short-name>
    <uri>WEB-INF/sampleTag</uri>
    <display-name>SampleTag</display-name>
    <description>Sample TLD</description>
    <tag>
    <name>time</name>
    <tag-class>com.sample.taglib.TimeTag</tag-class>
    <body-content>empty</body-content>
    </tag>
    </taglib>
    Anybody can tell me why?
    Thanks!!!

    It's strange bacause DTD is available under given address.
    Which JSP version are you using?
    Do you have any other tld file, which uses the same DTD version? Do tags define in it work properly?
    Maby try to use 1.1 version of DTD?
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">But remember than version 1.1 has another node names (see http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd).

  • Simple Doubt in JSP

    I have a set of check boxes and corresponding text boxes in a HTML form. I want to display the text box value if the corresponding check box is checked.
    Can anybody tell me how to accomplish this?

    I have a set of check boxes and corresponding text
    boxes in a HTML form. I want to display the text box
    value if the corresponding check box is checked.
    Can anybody tell me how to accomplish this?when are you trying to display the text box value? After they hit a submit button or something? If thats true then you can if you want write a servlet or jsp which will handle the POST action. Then you can get the value depending on what you named it in them in the JSP.
    So if you named your field something like:
    <input type="text" name="text_one"/><input type="checkbox" name="mycheckbox" value="one"><br>
    <input type="text" name="text_two"/><input type="checkbox" name="mycheckbox" value="two"><br>
    <input type="text" name="text_three"/><input type="checkbox" name="mycheckbox" value="three"><br>
    Now you can do:
    String[] checkBoxValues = request.getParameterValues("mycheckbox");
    for(int i = 0; i < checkBoxValues.length; i++) {
    if(checkBoxValues.equals("one"))
    System.out.println(request.getParameter("text_one");
    else if(checkBoxValues[i].equals("two"))
    System.out.println(request.getParameter("text_two");
    else if(checkBoxValues[i].equals("three"))
    System.out.println(request.getParameter("text_three");
    Obviously there probably way better ways to do this but this should at least lead you in the right direction.
    -Chuy

  • Hi... A simple question of JSP...

    Hi All,
    Do anybody know how can I pass chinese character from a html to JSP???
    should I encode it first?
    I have tried to pass it as normal character.. but the JSP can't get it correctly...
    Vincent

    Question is: if your chinense character (in html) is in unicode(UTF-8)
    ,or it is char from special chinense character set,or html special char.
    If it is html special char->jsp will show it correctly.
    If not:
    To head of jsp give:
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    If this character is in utf-8 it will be ok.
    If this char is from chinense charset you must decode it to utf-8.
    Hi All,
    Do anybody know how can I pass chinese character from
    a html to JSP???
    should I encode it first?
    I have tried to pass it as normal character.. but the
    JSP can't get it correctly...
    Vincent

  • Simple question on /jsp:useBean

    Hi,
    I have a bean within my jsp page. My page doesnt have the </jsp:useBean> code. When users go to my site everything is good. If they hold down F5 for a while, the page hangs and it hangs the whole site until its finished. Its like hold down F5 for 30 = submitting hundreds of jobs that just fill up the jsp server.
    1) Should i be using the usebean end tag???
    2) Is there a way to kill the previous process when user hits f5=refresh, so all the processes dont build up??
    3) Would not using the </jsp:useBean> cause this build up????
    Thanks so much. I will take any information that I can get.

    Hi,
    I have a bean within my jsp page. My page doesnt have
    the </jsp:useBean> code. That is fine the scope of the bean ends once the page ends.If you use the tag then the engine will instantiate the bean for you,i believe you will be importing the class and then instantiating it.
    When users go to my site
    everything is good. If they hold down F5 for a while,
    the page hangs and it hangs the whole site until its
    finished. F5 means refreshing the page is sending the request back to the servlet instance(jsp),So if there are 100 requests send then there will be 100 threads using the same instance of the servlet if single theread model is not implemented.As I specified 100 threads using same instance the control will not go to next request thread unless first finishes(Without single thread model).in jsp use can use
    isthreadsafe=false to implement the Single thread model.
    Using this model will create the multiple instances of the servlet and improve the efficiency but more allocations will be held.
    1) Should i be using the usebean end tag???Don't require to do,should be able to work explicitly
    2) Is there a way to kill the previous process when
    user hits f5=refresh, so all the processes dont build
    up??Killing the previous process is the wrong term to say actually u should ask for the previous request ie Thread.The process killing means killing the JVM(System.exit(0)),ie stopping the engine.
    The previous thread cannot be controlled by one who has created and it is the engine who has created the request threads.I wont say that cannot be done but requires to modify the container code and if you do so you will bw deviating from the specifications.
    What you can do get the responses faster by implementing the singleThread model(In jsp use istheeadsafe=false in jsp page tag).
    Hope this will help you.
    regards vicky

  • Urgent! Simple master detail jsp without ADF.

    We need to develop a master detail page. personal and detail process record for that personal.
    This will work on the web so We are using jsp technology.
    (We are using tomcad so We can't use ADF because of deployment problem. maybe the fallowing phase ADF will be used.)
    We can't find these kind of sample java and web. Especially data grid type interface on the web.
    This is very important program and we need urgently finish.
    Thanks for your help.

    You can use ADF with Tomcat, you just need to install the ADF runtime libraries on your tomcat.
    There is a toole->install ADF Runtime option for this.

  • Problem with a simple hello world JSP

    We have just installed WLS Express 7.0 (just downloaded) on a Solaris 8 server. Using the dmwiz.sh, we have created a new domain with a managed server. Both the Admin Server and managed server have started and are running. When I tried to load a sample web application (a war file that has a hello world JSP), I got a HTTP 500 internal server error in serving the hello.jsp page. This sample works fine in Windows WLS Express 7.0.
    Can someone please help? Thank you in advance.

    Alex <[email protected]> wrote:
    We have just installed WLS Express 7.0 (just downloaded) on a Solaris
    8 server. Using the dmwiz.sh, we have created a new domain with a managed
    server. Both the Admin Server and managed server have started and are
    running. When I tried to load a sample web application (a war file
    that has a hello world JSP), I got a HTTP 500 internal server error
    in serving the hello.jsp page. This sample works fine in Windows WLS
    Express 7.0.
    Can someone please help? Thank you in advance.Hi,
    It seems the installation of the server worked fine as you were able to start
    the servers.
    You may try posting this message to the weblogic.developer.interest.jsp newsgroup.
    If you are
    not using the latest service pack, please try using that.
    regards,
    Platform Team
    BEA Systems

  • Simple Request problem + jsp

    I have this on my page:
    String[] faultTypes = (request.getParameterValues("faultType")!=null)?request.getParameterValues("faultType"):"";
    But everytime I enter the page, I get the following error. Any iidea how I would go abou correcting that.
    C:\Tomcat 4.1\work\Standalone\localhost\faults\admin\faultreport\ViewDetails_jsp.java:112: incompatible types
    found : java.lang.Object
    required: java.lang.String[]
         String[] faultTypes = (request.getParameterValues("faultType")!=null)?request.getParameterValues("faultType"):"";

    Or even tried this.
    String[] faultTypes = (request.getParameterValues("faultType")!=null)?request.getParameterValues("faultType"):new String[0];
    My form looks like this.
    <FORM METHOD="GET" ACTION="ViewDetails.jsp">
                             <tr valign="top">
                             <!--<td align="right" bgcolor="">TemplateBeginEditable name="Label3" </td>-->
                             <td colspan="2" bgcolor=""><!-- TemplateBeginEditable name="Value3" -->
                             <input type="checkbox" name="faultType" value="network"><FONT SIZE="2" COLOR="" class="unnamed1">Network Related</FONT>                      
                             <input type="checkbox" name="faultType" value="vandalism" ><FONT SIZE="2" COLOR="" class="unnamed1">Vandalism</FONT>  
                             <input type="checkbox" name="faultType" value="stone" ><FONT SIZE="2" COLOR="" class="unnamed1">Stone Related</FONT>                 
                             <INPUT TYPE="reset" class="unnamed1" value="Clear"> 
                             <INPUT TYPE="submit"class="unnamed1" value="Submit"> 
                        <!-- TemplateEndEditable -->
                        </td>
                        </tr>
                        </FORM>

Maybe you are looking for

  • Independent backup of iPod nano

    Hi: Can I backup my iPod Nano by simply copying all files (hidden etc.) off of it from its My Computer drive mapping? I ask because I just went thru the anguish of the dreaded "iPod recovery". If I can make periodic backups of it outside the iTunes s

  • Battery not sitting correctly in laptop.

    Mac OX X 10.6.8 processor 2.13 GHz Intel Core 2 Duo Memory 4 GB 800 MHz DDR2 SDRAM Suddenly noticed that the removable battery in my laptop is not sitting correctly in it's receptacle. I took it out and examined it and noticed it is slightly misshape

  • New MacBook seems slower than it should be

    I have had my new 2Ghz Core 2 with 2GB of ram for about a month or so now and I have to say I have not been that impressed with the speed of the machine. It boots, and shuts down like a blaze and once applications have been opened and closed once the

  • Error IMAQdx with Tuscen camera

    Hello, In my lab computer that run with window xp and have labview 2013. When I try to open my Discovery MH15 Tucsen camera I received  "Error 0x80040154 The configured external lighting mode is invalid". On different computer (window 7 Labview2011)

  • MY First Package/Proc

    Hello, It has been a couple of years since I took and Oracle class, so I am a bit rusty. I am trying to figure out the syntax on how to create the body of a package. My "Procedure" is very simple, read in a couple of parms and output some fields (mul