Home Tutorialhelp Comment Your code has lots of errors

 
 

Comment

Greg
Your code has lots of errors,
March 2, 2009 at 11:57 PM

I cleaned up your code. It had multiple errors with return types, misspelled variables and classes, and illegal characters.

This compiles correctly:

cd C:\j2ee\jdk\bin
javac -classpath C:\j2ee\lib\j2ee.jar C:\tomcat\webapps\tutorials\WEB-INF\classes\taglib01\Helloworld.java


the class:

package taglib01;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class Helloworld implements Tag {

private PageContext pagecontext;
private Tag parent;

public int doStartTag() throws JspException
{
return SKIP_BODY;
}

public int doEndTag () throws JspException
{
try {
pagecontext.getOut().write("Hello World");
}
catch(java.io.IOException ex)
{
throw new JspException("IO Exception");
}
return EVAL_PAGE;
}

public void release (){}

public void setPageContext(PageContext p)
{
pagecontext=p;
}

public void setParent(Tag t)
{
parent = t;
}

public Tag getParent()
{
return parent;
}
}

Since this is the first taglib tutorial I've ever tried, it was frustrating. It took me many hours to find out why.

The problem is in your class.

First of all, "Package" is lowercase. "Import" is also all lowercase. "Public" is also all lowercase.

"PageContext" needs to have capital "P" and "C", not just capital "P".
The property "pagecontext" doesn't have a capital "C".

The "JSPException" is also misspelled. It should be "JspException."

In the try/catch, "java.io.Exception" should be "java.io.IOException" - there is no "Exception"...it doesn't exist.

In your setPageContext() method, the data type of variable p is PageContext, not pageContext.

In your getParent() method, you have "void" for return type. It should be "Tag" instead of void.

You used illegal double quotes in 2 argument lists.

pagecontext.getOut().write()

and

throw new JspException()

They seem to be extended ASCII double quotes, probably from Microsoft Word, or UTF-8 encoding. They won't work strings in argument lists!

Also, in your setParent() method, the assignment is incorrect. You are assigning it to a variable which isn't declared. It should be this:
pagecontext=p;

Not this:
pageContext=p;

Even though your code is horrible, I learned a lot by fixing it.
Sir, you can't just put tutorials like this online without testing the code for yourself!
There are a lot of beginners who need good tutorials. They need help, not confusion.
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

errors
that what the errors in above code 

Java Beginners

Getting 404 errors - Java Beginners
much.   Hi Friend, We have modified your code, try the following... { /* TODO output your page here out.println... I received a 404 errors and I identified that the servlet doesn't appear 

Java Beginners

Compiler errors in java
Compiler errors in java  Hi, I used GenerateRDF java file. Am getting errors when i run this code. I used command prompt only. getting errors as no package exist. i followed your instructions properly. Please help me out 

Java Beginners

need to fix errors please help
modified your code. Check it. import java.io.*; class InputName{ static...need to fix errors please help  it does have 2 errors what should i...; String name2; System.out.println("please enter your name:"); name1= input.readline 

Java Beginners

<errors><error><domain>yt:quota</domain><code>too_many_recent_calls</code></error></errors>
? Thanks   Hi, If your application is receiving such error, then stop your application and wait for 10-15 minutes. Then start the application, after... if your limit exceeds the quota. You will get the error in following xml format 

JSP Tutorials

Runtime Errors
Runtime Errors          Errors are arised when there is any logic... to divide the number by zero which results in runtime error. The code of the program 

JSP Servlet Questions

jsp errors - JSP-Servlet
jsp errors  Hi I got errors when running a jsp file I am giving the file. this is from rose india. I set the class path for 3 jar files i.e.... Now i am getting less errors compared to previous. But I am getting 2 errors 

Core Java

Ask Programming Questions and Discuss your Problems
has introduced a new killer instinct tool that is committed to eradicate your... read this. This will help you enormously and can save your lots of time. Before... Ask Programming Questions and Discuss your Problems   

Java Beginners

What is the errors?
What is the errors?  ) while ( c <= 5 ) { product *= c; ++c;   if ( gender == 1 ) cout << "Woman" << endl; else; cout << "Man" << endl;   Post the whole code 

PHP Tutorial

How to show all errors in PHP?
make changes in your code for displaying all the warning and error messages... the errors while developing PHP programs. What change I should make in the code... and warning messages. You can have to add the three lines of code in your PHP 

Hibernate Questions

Calling hibernate query list() method generates errors
asking your help about this. I am trying to retrieve a list of jobs from... identifier exists: [Job#:jb4567]... But in the db, the table has data. I'm... of the job id from REFRESH to PERSIST, but still the same errors occur. Does cache 

Ajax Examples

Your Bubblez
unfunded company that has lots of new concepts to offer. We do look for bright... Your Bubblez       Your... your desktop windows but within your browser on a single DHTML page. You can draw 

JSP Servlet Questions

jsp code problem - JSP-Servlet
jsp code problem  hi, I am going to execute the following code which has been given your jsp tutorial. retrive_image.jsp: but while I try to execute the code it gives the following error message in the tomcat 

JSP Servlet Questions

Servlets errors in same page.
Servlets errors in same page.  How do I display errors list in the same page where a form field exists using servlets...........i.e. without using JSP? Please explain with a simple username password program 

JDBC Questions

verify the code and give me the code with out errors
verify the code and give me the code with out errors   import java.awt.*; import java.awt.event.*; import javax.swing.border.Border; import... clear the errors and give me correct tutorial for my knowledge improving.pls anyone 

Java Beginners

Java Program Errors
Java Program Errors  These are the 2 errors which I am getting when executing the java source code extracted from executable jar file The project was not built since its build path is incomplete. Cannot find the class file 

Programming Tutorials

How to promote your writing through your website
not easy to use then he will skip it and move on. After all he has lots of other... How to promote your writing through your website  ... to promoting your latest book? Tired of the endless running around after 

Ajax Examples

Ajax Code Libraries and Tools
;    Code libraries and loots for the development of your Ajax... on running the code on your own server see Running the jMaki Sample Application... from the simplest tasks like editing small sections of code for your site 

Java Beginners

Correct errors - Java Beginners
Correct errors  Identify and correct the errors in the following program: public java Method { public static method1(int n, m) { n += m... Friend, Try the following code: public class Example{ public static void main 

Struts Questions

I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?
I tried to create a dropdown list using struts2.it is not working.can you find the errors in this code?  /jsp code for creating dropdownlist using struts2/ <html> <body> <p:form action="addemp" method="post"> 

JSP Servlet Questions

jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months 

Java Beginners

Java errors - Java Beginners
Java errors  I need help sorting parallel arrays. I've done about 75% of the code myself, but it's ugly and I can't get it to run. One array contains a list of names, the other a list of corresponding numbers. One sort must 

Java Beginners

errors
 

JSP Servlet Questions

Exception: java.lang.IllegalStateException: getWriter() has already been called for this response - JSP-Servlet
Exception: java.lang.IllegalStateException: getWriter() has already been called for this response    response.setContentType("text/html;charset..._Name, Stud_Photo FROM StudentMaster WHERE (Stud_Code = '"+request.getParameter 

JSP Servlet Questions

code in jsp
code in jsp  hi.. I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a code to sort a list of students on the basis of there 12% marks and AIEEE 

IDE Questions

Need urgent help with C++ errors!
Need urgent help with C++ errors!  hi, i'm new to C++ programming. this is my code... i'm using Turbo C++. It's showing so many errors!.. I...() { cout<<"Can somebody fix this?"; } the errors are listed as follows 

Java Beginners

JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message 

Programming Tutorials

Submit Your Article
Submit Your Article       Submitting Your Articles to the articles search engines are an important step towards popularizing your articles. Submitting your articles brings Traffic 

Framework Questions

getOutputStream() has already been called for this response
exception: java.lang.IllegalStateException: getOutputStream() has already been called for this response. here is my jsp code: <%@ page import...getOutputStream() has already been called for this response  hi 

JSP Servlet Questions

Html/JavaScript code - JSP-Servlet
to JSP2. 3.JSP2 has a return button on it, that redirects to JSP1. 4. My issue..., ------------------------------------------ If, you have any problem then , please send me detail with code. Thanks.  ok this is code snippet of JSP1 that is used to display teh table. --JSP1 

JSP Servlet Questions

jsp code - JSP-Servlet
jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page of hyperlink 4) bottom page has to display footer example header 

JSP Servlet Questions

jsp code - JSP-Servlet
jsp code  i want to design page into four pages 1) header to diplay 2) left page has to display hyperlink 3)right page has to display related page of hyperlink 4) bottom page has to display footer example header 

Java Beginners

remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable...(); } } print("code sample 

Java Beginners

remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable...(); } } print("code sample 

Java Beginners

remopving errors incore java programming
remopving errors incore java programming  sir error in program:-file does not contain class runnable program:- class MyRunnable implements Runnable...(); } } print("code sample 

Struts Questions

How to validate a form in action class and forward errors to the jsp in struts?
How to validate a form in action class and forward errors to the jsp in struts?  How to validate a form in action class and forward errors to the jsp in struts 

JSP Servlet Questions

jsp code - JSP-Servlet
jsp code  how to get multi-chat client using jsp? i will be very glad if i'd get an idea from you people. thank you .  Hi Friend.... To start chatting you must be connected with the server after that your message can 

General

Commenting out your code - Java Tutorials
errors But the given below code compile : public class Sample2...Commenting Erroneous Code & Unicode newline Correct In this section, you will find an interesting  problem related to commenting erroneous code 

JSP Servlet Questions

JSP code - JSP-Servlet
JSP code  Hi! Can somebody provide a line by line explanation of the following code. The code is used to upload and download an image. <... have successfully upload the file by the name of: Download /*Code 

Java Tips and Examples

Controlling your program
Controlling your program      ... flow statement. It directs the program to execute a certain section of code. This code gets executed if and only if the test evaluates to true 

Applet Questions

Help please, some strange errors
. As a beginner in java i got no idea which part of the code is creating this errors so i have posted the whole program here. Here i tried to make the monopoly... play the error hits on to the console view. Can someone tell me what in the code 

Programming Tutorials

Right Way of Planning Your Articles
Right Way of Planning Your Articles Article writing is a creative as well as competitive task. A plethora of writers are available nowadays which has made... efforts. It is necessary that you get rid of all of your dread related 

Struts Questions

how to display action errors in jsp which is in a form list
how to display action errors in jsp which is in a form list  My jsp contains list of forms iterating using display:table, each FORM forms a row. I want to display action errors for individual form in the same row 

iPhone

Protecting Your iPad Has Never Been Easier
Protecting Your iPad Has Never Been Easier Since its release early in 2010, the iPad has been flying off the shelves in stores all over the world... enhanced. What many people don’t actually pay attention to is how to keep your 

Java Beginners

explanation to your code - Java Beginners
)?And i have imported many classes.but in your code you imported a very few classes.sir i need your brief explanation on this code and also your guidance.this...explanation to your code  sir, I am very happy that you have 

JSP Servlet Questions

Jsp Code Problem - JSP-Servlet
Jsp Code Problem  I use DocType in my Jsp Page. The Links are not functioned after Applying the DocType. Could you tell me any way to activate the link. Thank You.   Hi Friend, Please send your code. Thanks 

Struts Questions

Display Errors using Message Resources - Struts
Display Errors using Message Resources  Hello.. I've a login page where i used applicationresources.properties to display errors for null values and i wrote the condition in formbean. Now i want to show the errors for invalid 

JSP Servlet Questions

jsp code error - JSP-Servlet
jsp code error  I have a jsp page named "tMastDepartment".which has some table row containing text box like 'project code','Departmentcode','employee... there is the problem which i am facing.what will be the exact code 

Android

Android Unknown Facts
with lots of amazing features and promoted by a group of more than 30 renowned... the lesser-known Android facts that are sure to catch your interest in this superb... Android source code open means many developers will be attracted to the development 

Java-Tutorials

Exception Handling
the errors occurred in the program. In the following example code you will see that how...; Exception, that means exceptional errors. Actually exceptions are used for handling errors in programs that occurs during the program execution 

Development process Questions

Jsp Code - Development process
d jsp code . Thanks Prakash   Hi Friend, We are providing you the JSP code where we have retrieve the data through the date fields.In database we...Jsp Code  HI, I have 5 fields including date "from date" and "to date 

JSP Servlet Questions

code in single jsp - JSP-Servlet
in single jsp it would be useful the code which u gave is 1)click.jsp...code in single jsp  hi the code is good but for my application i need to click a link and it has to go to the specified page and also count 

Eclipse Plugins

Eclipse Plunging Source Code Analyzer
; Eclipse Metrics This plug in calculates various metrics for your code... of your code base.     FindBugs Plug-in FindBugs...;bug patterns" - code instances that are likely to be errors 

Ajax Questions

Ajac code with jsp - Ajax
Ajac code with jsp  hi , i am beginner for ajax.I have to perform some calculation on my jsp page. i want to do it automatically.... Thanks Rahul  Hi friend, Plz give some details about your 

JSP Servlet Questions

source code - JSP-Servlet
source code  please i want source code for online examination project (web technologies)  Hi Friend, Send some details of your project. Thanks 

Java Beginners

JSP Code - Java Beginners
JSP Code  Dear Frnds, I m using a 'multiple selecttion in List... Vinay Kumar Rai   Hi Friend, Try the following code: 1)combo.jsp: Select your favourite Cars: Alto Nano Innova Esteem Swift Safari 

Java Beginners

JSP Code - Java Beginners
JSP Code  Dear frnds, I have a problem where i need to display... item, another query has to be executed. something like: String drpvalue... where role_name='"+drpvalue+"'" 3. Based on query sql, data has 

Ajax Questions

code for jsp - Ajax
code for jsp  please give code for using jsp page and Ajax.Retrive... country.By using jsp and Ajax.    Hello Friend I send the code you have to modify it by providin your driverclass, username and password 

JSP Servlet Questions

jsp error - JSP-Servlet
jsp error  HTTP Status 404 - /jsp... message /jsp/ description The requested resource (/jsp/) is not available..., The 404 or Not Found error message is an HTTP standard response code indicating 

Java Beginners

JSP code - Java Beginners
JSP code  Hi, Im trying to do a report which should generate...: ----------------------------------------------- code rep_number desc...;% db.connect(); rsUser = db.execSQL("SELECT * FROM reportID WHERE code = 'J 

Ajax Questions

ajax and jsp code - Ajax
ajax and jsp code  can u please give me the code for retriving... in listbox display the corresponding all the states. using jsp and ajax   Hello You have to change here your database name , tablename, column name 

JSP Servlet Questions

source code - JSP-Servlet
source code  i want source code for my project online examination it includes two modules user and administrator so if user want to write exam first... terminate your questions 

JSP Servlet Questions

source code - JSP-Servlet
source code  i want source code for my project online examination it includes two modules user and administrator so if user want to write exam first... terminate your questions 

JSP Servlet Questions

code error - JSP-Servlet
complaint   Hi friend, Do some changes in your code to solve the problem. 1)In "describe()" function write code "return true"; 2...code error  hii this program is not working becoz when the mouse 

Software Services

Portal Development ' A Step Towards The Success Of Your Business
at the amount of business online today. Your website has got to be up to date and snazzy...Portal Development – A Step Towards The Success Of Your Business Web... to take not of when it comes to your website is your portal. If you aren’t 

Eclipse Plugins

AppPerfect Code Analyzer
Practices which leads to optimization of your application. AppPerfect Code Analyzer performs analysis of your Java and Java Server Pages (JSP) source code... your own organization's custom rules. A wide range of errors are reported 

Development process Questions

To call jrxml/jasper file through jsp code in netbean
To call jrxml/jasper file through jsp code in netbean  I am making... my question is I want to call that jasper file through my jsp code and i also... to it. Your suggestion has valuable to me 

Eclipse Plugins

Eclipse Plunging Source Code Analyzer
Metrics This plug in calculates various metrics for your code during build.... This allows you to stay continuously aware of the health of your code... patterns" - code instances that are likely to be errors. The FindBugs 

Java Beginners

java code to search in your hard disck
java code to search in your hard disck  Build a search engine which would scan your hard disk and build an inverted index for your files. The search engine should cluster your files according to some criteria and make some 

Java Beginners

I need your help - Java Beginners
I need your help  For this one I need to create delivery class... represent the area. E.g, the 76th delivery in 2010 has a complete delivery number of 20100076). (Code to representing the delivery area either 1 for local delivery 

JSP Servlet Questions

a jsp code for creating a text file
a jsp code for creating a text file  Hello,i need jsp code... a new data file. So i need a jsp code for following options. when user login then the following has to be displayed for user 1.Creating the new file 2.delete 

PHP Questions

getting error in your login form code
getting error in your login form code  i tried your code for login... and password.the code is $fuser=$POST["userid"];. how to solve this problem please help me   hi friend, your form's input must have following : <input type 

Date Calendar

What is License Terms for using your code
What is License Terms for using your code   Hi, I have used Datepicker.java with some modification from your site. Can you please inform me what is the License terms for using it ? Thanks Venkatesh .P 

JSP Servlet Questions

Database connectivity with jsp code - JSP-Servlet
Database connectivity with jsp code  I have written a program in java having connectivity with online_exam. Its working properly. Connection has been established and the code in java is showing the output. But the problem 

XML Tutorials

Handling Errors While Parsing an XML File
Handling Errors While Parsing an XML File       This Example shows you how to Handle Errors While... to create new DOM parsers.There are some of the methods used in code given 

JSP Servlet Questions

in the below code two errors are there one at the button onclick atttibute and the next is at the next button
in the below code two errors are there one at the button onclick atttibute and the next is at the next button  <%@ page import="java.sql.*" %> function editRecord(id){ var f=document.form; f.method="post 

JavaScript Questions

jsp code
jsp code  what are the jsp code for view page in online journal 

JSP Servlet Questions

java Compilation error:jsp code - JSP-Servlet
java Compilation error:jsp code   I am getting an Generated Servlet... code: <% { Dbclass2 d= new Dbclass2... action='/Employee_App1/add1.jsp' >"); out.println("<TABLE border='3 

General

Ask JSP questions online
your questions and forget the pain.  JSP refers to Java... Ask JSP questions online       Facing problem in JSP? Ask to us, we 

JSP Servlet Questions

code for LAN Messenger - JSP-Servlet
code for LAN Messenger  User has to add the Valid System Name... the System Name User has to enter the Message to be send to the Selected System. After... SEND TO RELATED CODE FRO THIS PLSE 

HTML Questions

check for errors
check for errors  How can I check for errors 

JSP Servlet Questions

JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml 

Spring Framework Questions

the JDBC Driver has been forcibly unregistered
the JDBC Driver has been forcibly unregistered  Hi my application... errors Feb 1, 2011 10:28:53 AM org.apache.catalina.loader.WebappClassLoader... application was st opped. To prevent a memory leak, the JDBC Driver has been 

JSP Servlet Questions

jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code... visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml www.roseindia.net/jsp/searchbook.shtml 

Java Beginners

computation code - Java Beginners
computation code  "Helo man&sir can you share or gave me a java code... and tells them to try again. After a sales amount has been entered for each... running your program, depending on the data entered. This is a sales tracking 

JSP Servlet Questions

jsp code
jsp code  i want health management system project code using jsp.its urgent 

VoIP

Free VoIP Gateways: VoIP Gateways for Your business
Free VoIP Gateways: VoIP Gateways for Your business   ... of Free VoIP Gatways that you can use to connect the VoIP network to your public... your PTSN, even if you are using an IP-based system, just like your traditional 

JSP Servlet Questions

JSP - JSP-Servlet
" Your File has been...JSP  Hi! JSP In my project I have to upload word documents in server... what path i have to give in code.  Hi friend, Code to help 

JSP Servlet Questions

servlet/jsp - JSP-Servlet
servlet/jsp  hi, get me the source code to upload all file formats in servlet/jsp plaese help me as soon as possible its urgent!!! by saravanan.k  Hi friend, Code to help in solving the problem 

JSP Servlet Questions

jsp runtime error - JSP-Servlet
jsp runtime error  sir, when i am running ur prog... from this website.... http://www.roseindia.net/jsp/poi/readingWriting.shtml i did the same...: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated 

JSP Servlet Questions

JSP - JSP-Servlet
select box value then that value has to pass and executing the jdbc code... in one JSP page. in this page i have 2 select boxes.when ever i select first select option then the second box has to be filled depend on this value,but here 

JDBC Questions

Need Java Source Code - JDBC
be implemented.  Hi friend, Please send me code because your posted... the Id, for eg: "E001" has to be generated automatically when ever i click.... http://www.roseindia.net/jsp/ Thanks 

JSP Servlet Questions

JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code 

Struts Questions

Deployment of your example - Struts
Deployment of your example  In your Struts2 tutorial, can you show how you would war it up so it can be deployed into JBOss? There seems to be a lot... send me code and explain in detail. Visit for more information. http 

JSP Servlet Questions

jsp code
jsp code  i want to jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type code,,,,plz help me 

Spring Framework Questions

SEVERE: Context [/hospital] startup failed due to previous errors
org.apache.catalina.core.StandardContext start SEVERE: Context [/hospital] startup failed due to previous errors Jan... nam Thread-3] but has failed to stop it. This is very likely to create a memory 

JSF Tutorials & Examples

Developing JSP files
application has 10 JSP pages. login.jsp success.jsp useraccount.jsp...; <h:form> <h:outputText value="Your account password has been... Developing JSP Files      

JSP Servlet Questions

redirecting a login authenticated form to a form to be displayed on the same page from where the login authentication has taken place.
page from where the login authentication has taken place.  I am...;The given code accepts username and password from the user and check whether the user... { response.sendRedirect("/examples/jsp/login.jsp"); } } catch 

JSP Servlet Questions

Jsp - JSP-Servlet
Jsp  Hi! Friend thanks for your reply. Now it is working. My project has been completed with your help.. I got a new project. In that project I am... wrote the code for first combo i.e. country and I got it. In the dbase country 

JSP Interview Questions

JSP
organization. OSCache has a set of JSP tags that make it easy to implement page caching in your JSP application. Following are some Cache techniques...JSP  how did you implement caching in jsp   OSCache 

Advertisements Advertisements
 

 

 

DMCA.com