473,802 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JSP Getting Started

539 Contributor
I have a subject that covers JSP(new to me), accessing database through JSP(new to me), applets, UML(also new to me)

So, as im learning java, all i did to learn faster is i've created some applications(wi th sense). With my style of self learning, i hope it could be effective in JSP too....

I like to be advanced on the planned topic to be discussed by our instructor(He is not a certified Java Programmer though)

So now, all i know about JSP is the following:
-basic tags
expression <%= something%>
declaration <%! something%>
i dont know the term <% something %> I think it is an invocation
equivalent to java (Please correct me on that part)

-Setting up tomcat.
-The ROOT folder
-WEB-INF theoritically knew where to put classes/jars etc....
(though im not tested them yet)
-getting the value of a html form through request.getPara meter("form input-type name)

Those are basics obviously...( I learned them through surfing)

And im planning to create a simple application.
What comes on my mind is to reimplement my previous project (Simple Hotel FrontDesk System) into Online Hotel Reservation System
-the registration is obviously done by the hotel frontdesk only....
-Maybe the BlackList feature would be added if i knew the real ( Deep )

Actually, we have proposed a project "Online Entrance Exam" to our instructor and he likes it... so he approved our proposal.....( Not Thesis )

But before we start banging that project, deadline is on October ( Final week in this semester )

I like to grasp the essentials of JSP and also the other techniques, new way, and theory behind that architectural design for web application platform....
(Please correct me on the phrase above)

Actually, the faculty decided to order a J2EE book from Sun( i think the book base is in Singapore) for about 2500php or $56.00

Unfortunately, that book is expected to be arrived on midterms.... unbelievable scenario(but that was true)....

I did attempt to buy a new book instead of waiting that precious book, but i doubt for having such book....(for $40.99)....

So i decided to wait that precious book, yet learning in advance from this forum and the other web resources....

What a long story :)

Well, anyway,

Here is what i suppose to know in JSP as im building my experimental application for the supplement on my final project( Not thesis though )

I like to know about the JSP Beans,

for example, i have a java class that contains setter and getter methods,
i like to jar them, unfortunately, i didn't found the right tutorial for it on the web...

so can you post a helpful url that would teach me how to do that?
and also, about how to access the jar file from the jsp container( doubt of terms )Please correct me....

Or can you show an example?
For example, i have a jar file in WEB-INF/lib/JARZKY.jar
and the content is com\myclass.cla ss(with setSetter() and getGetter() methods)

How can you invoke that class through JSP?


A sincere Java Lover,
sukatoa
Jul 3 '08 #1
35 3658
r035198x
13,262 MVP
First read this one.
Then get this one which is free from sun for the more serious stuff.
Jul 3 '08 #2
sukatoa
539 Contributor
First read this one.
Then get this one which is free from sun for the more serious stuff.
Thanks for the URL r035198x....
Im on my way.....
Jul 4 '08 #3
sukatoa
539 Contributor
Thanks for the URL r035198x....
Im on my way.....
I have created a jar named Checker.jar
saved on WEB-INF\lib\

my problem is i cannot access the Checker.jar
with content dma.Checker.cla ss

i've attempt:

<jsp:useBean id="Checker" scope="page" class="Checker" />

attempting to replace class into jar ==> invalid attribute

But i really have no idea how to fix this.....

Can you show me an example about this?
The url above does only explains how to deal with classes...( not jar )
Jul 4 '08 #4
sukatoa
539 Contributor
Is this possible?

I would like to add a text file together with the classes folder inside WEB-INF
And that text-file is the source to be extracted for calculations and i will try to open that textfile from my java-bean.... possible? or not?

for example,
I have a text file that contains the list of all countries....
That is really disapointing on my part that all the countries will be coded on
bean. so i decided not to do it inside the code, instead on the database....
But for that it is just a constant data, having it on the database will add
another table and it will consume another bean that has 100 lines of code
(Approximately) . Before attempting it into database, i need your advice, and
the answer on the above questions experts....

Looking forward on your replies,
sukatoa....
Jul 11 '08 #5
sukatoa
539 Contributor
Im currently doing some experiments in JSP........

and I fail to debug my code.....

Here is the stacktrace:
Expand|Select|Wrap|Line Numbers
  1. org.apache.jasper.JasperException: For input string: ""
  2.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
  3.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  4.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  5.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  6.  
  7.  
  8. root cause 
  9. java.lang.NumberFormatException: For input string: ""
  10.     java.lang.NumberFormatException.forInputString(Unknown Source)
  11.     java.lang.Integer.parseInt(Unknown Source)
  12.     java.lang.Integer.valueOf(Unknown Source)
  13.     org.apache.jsp.home.guests.Validator_jsp.checkAccountInformation(org.apache.jsp.home.guests.Validator_jsp:63)
  14.     org.apache.jsp.home.guests.Validator_jsp._jspService(org.apache.jsp.home.guests.Validator_jsp:270)
  15.     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  16.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  17.     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
  18.     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  19.     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  20.     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am curious about that inputString.... .....

Here is the JSP code.

Expand|Select|Wrap|Line Numbers
  1. <%@ page 
  2.     contentType="text/html; 
  3.     charset=iso-8859-1" 
  4.     language="java" 
  5.     errorPage=""
  6.  
  7.     import = "beans.specific.constants.ImageRefGenerator"
  8.     import = "beans.reusable.checker.EmailChecker"
  9.     import = "java.util.ArrayList"
  10.     import = "java.util.GregorianCalendar"
  11. %>
  12. <jsp:useBean id="signupcookie" class="beans.specific.cookies.SignUpCookie" scope="session" />
  13.  
  14. <%!    
  15.     ImageRefGenerator img = new ImageRefGenerator();
  16.     String SenderLocation = "http://localhost:8080/home/guests/register.jsp";
  17.     EmailChecker checkemail = new EmailChecker();
  18.     ArrayList<String> reminder = new ArrayList<String>();
  19.  
  20.     private final boolean checkVerification(String confirm,String reference,boolean strict){
  21.         if(confirm.length()>0){
  22.             if(!strict)
  23.                 return confirm.equalsIgnoreCase(reference);
  24.             else
  25.                 return confirm.equals(reference);
  26.         }else{
  27.             return false;
  28.         }
  29.     }
  30.  
  31.     private final boolean checkMail(String email){
  32.         checkemail.resetValue(email);
  33.         return checkemail.checkStoredEmail();
  34.     }
  35.  
  36.     private final boolean checkAccountInformation(String username,
  37.                                                   String password,
  38.                                                   String verifypassword,
  39.                                                   String emailaddress,
  40.                                                   String verifyemailaddress,
  41.                                                   String creditcardnumber){
  42.         boolean confirmer = true;
  43.         if(username.length()==0){
  44.             reminder.add("username");
  45.             confirmer = false;
  46.         }
  47.         if(password.length()<6){
  48.             reminder.add("password");
  49.             confirmer = false;
  50.         }    
  51.         if(!checkVerification(password,verifypassword,true)){
  52.             reminder.add("verifypassword");
  53.             confirmer = false;
  54.         }    
  55.         if(!checkMail(emailaddress)){
  56.             reminder.add("email");
  57.             confirmer = false;
  58.         }    
  59.         if(!checkVerification(emailaddress,verifyemailaddress,true)){
  60.             reminder.add("verifyemail");
  61.             confirmer = false;
  62.         }    
  63.         if(Integer.valueOf(creditcardnumber)<16){
  64.             reminder.add("ccnumber");
  65.             confirmer = false;
  66.         }
  67.         return confirmer;
  68.     }
  69.  
  70.     private final boolean checkMemberInformation(String surname,
  71.                                                  String firstname,
  72.                                                  String middlename,
  73.                                                  String homeadd,
  74.                                                  String birthdate,
  75.                                                  String gender,
  76.                                                  String country,
  77.                                                  String passport,
  78.                                                  String placeissue){
  79.         boolean confirmer = true;
  80.         if(surname.length()==0){
  81.             reminder.add("surname");
  82.             confirmer = false;
  83.         }
  84.         if(firstname.length()==0){
  85.             reminder.add("firstname");
  86.             confirmer = false;
  87.         }
  88.         if(middlename.length()==0){
  89.             reminder.add("middlename");
  90.             confirmer = false;
  91.         }
  92.         if(homeadd.length()==0){
  93.             reminder.add("homeaddress");
  94.             confirmer = false;
  95.         }
  96.         if(!checkBirthDate(birthdate)){
  97.             reminder.add("birthdate");
  98.             confirmer = false;
  99.         }            
  100.         if(gender.equals("Select")){
  101.             reminder.add("gender");
  102.             confirmer = false;
  103.         }
  104.         if(country.equals("Select Country")){
  105.             reminder.add("country");
  106.             confirmer = false;
  107.         }
  108.         if(passport.length()==0){
  109.             if(placeissue.length()>0){
  110.                 reminder.add("passportnumber");
  111.                 confirmer = false;
  112.             }
  113.         }else{
  114.             if(placeissue.length()==0){
  115.                 reminder.add("placeissue");
  116.                 confirmer = false;
  117.             }
  118.         }
  119.         return confirmer;                             
  120.      }
  121.  
  122.      private final boolean checkContactInformation(String landline,
  123.                                                    String mobile,
  124.                                                    String fax,
  125.                                                    String alteremail){
  126.          boolean ret = true;
  127.          if(landline.length()!=0||mobile.length()!=0||
  128.             fax.length()!=0||alteremail.length()!=0){
  129.              if(alteremail.length()>0){
  130.                  if(!checkMail(alteremail)){
  131.                      reminder.add("alteremail");
  132.                      ret = false;
  133.                  }
  134.              }                 
  135.          }else{
  136.              reminder.add("nonecontactinfo");
  137.              ret = false;                                              
  138.          }
  139.         return ret;
  140.      }
  141.  
  142.      private final boolean checkBirthDate(String data){
  143.          String month = data.split("-")[0];
  144.          Integer day = Integer.valueOf(data.split("-")[1]);
  145.          Integer year = Integer.valueOf(data.split("-")[2]);
  146.          boolean ret = true;
  147.  
  148.          if(month.equals("February")){
  149.              if(new GregorianCalendar().isLeapYear(year))
  150.                  ret=day>28?false:ret;
  151.              else
  152.                  ret=day>29?false:ret;
  153.          }
  154.  
  155.          if(month.equals("April")||month.equals("June")||month.equals("September")||
  156.             month.equals("November"))
  157.                 ret = day==31?false:ret;
  158.          return ret;
  159.      }
  160.  
  161.     private final void VoidVerification(){
  162.         reminder.add("remoteuser");
  163.     }
  164. %>
  165.  
  166. <%
  167.     signupcookie.resetInstance();
  168.  
  169.     String username = request.getParameter("username");
  170.     String password = request.getParameter("password");
  171.     String checkpassword = request.getParameter("checkpassword");
  172.     String emailaddress = request.getParameter("emailaddress");
  173.     String checkemail = request.getParameter("checkemail");
  174.     String creditcard = request.getParameter("creditcard");
  175.  
  176.     String surname = request.getParameter("surname");
  177.     String firstname = request.getParameter("firstname");
  178.     String middlename = request.getParameter("middlename");
  179.  
  180.     String month = request.getParameter("month");
  181.     String day = request.getParameter("day");
  182.     String year = request.getParameter("year");    
  183.     String gender = request.getParameter("gender");
  184.     String homeaddress = request.getParameter("homeaddress");
  185.     String companyaddress = request.getParameter("companyaddress");
  186.  
  187.     String country = request.getParameter("country");
  188.     String passportnumber = request.getParameter("passportnumber");
  189.     String passportissue = request.getParameter("passportissue");
  190.  
  191.     String landline = request.getParameter("landline");
  192.     String mobile = request.getParameter("mobile");
  193.     String faxnumber = request.getParameter("faxnumber");
  194.     String altermail = request.getParameter("altermail");
  195.  
  196.     String confirmation = request.getParameter("confirmation");
  197.     String ref = request.getParameter("ref");
  198.  
  199.     signupcookie.setUsername(username);
  200.     signupcookie.setEmailAddress(emailaddress);
  201.  
  202.     signupcookie.setSurname(surname);
  203.     signupcookie.setFirstname(firstname);
  204.     signupcookie.setMiddlename(middlename);
  205.     signupcookie.setBirthDate(month,day,year);    
  206.     signupcookie.setGender(gender);
  207.     signupcookie.setHomeAddress(homeaddress);
  208.     signupcookie.setCompanyAddress(companyaddress);
  209.  
  210.     signupcookie.setCountry(country);
  211.     signupcookie.setPassportNumber(passportnumber);
  212.     signupcookie.setPassportIssue(passportissue);
  213.  
  214.     signupcookie.setLandline(landline);
  215.     signupcookie.setMobile(mobile);
  216.     signupcookie.setFaxNumber(faxnumber);
  217.     signupcookie.setAlterEmail(altermail);
  218.  
  219.     String validValue = img.getValue(ref);
  220.  
  221.     boolean indicator = true;
  222.     String brtdate = month.concat("-"+day).concat("-"+year);
  223.  
  224.  
  225.     if(!checkAccountInformation(username,password,checkpassword,
  226.                                emailaddress,checkemail,creditcard)){
  227.         indicator = false;                           
  228.     }
  229.     if(!checkMemberInformation(surname,firstname,middlename,homeaddress,brtdate,
  230.                                gender,country,passportnumber,passportissue)){
  231.         indicator = false;
  232.     }
  233.     if(!checkVerification(confirmation,validValue,false)){
  234.         VoidVerification();
  235.         indicator = false;
  236.     }
  237.  
  238.     if(!indicator){
  239.         response.sendRedirect(SenderLocation);
  240.     }
  241. %>
  242.  
Im loosing hope with this problem.....

Im using DreamWeaverMX, manual set-up of Apache Tomcat........

Can you experts tell me where is it on the code?
Or can you suggest any alternatives for this?

waiting,
sukatoa
Aug 3 '08 #6
sukatoa
539 Contributor
Im always late to realize........ .

ArrayList indexOf(Object o) uses the equals method that can't be used to compare null values........

Gotcha!!!!!!!

Expand|Select|Wrap|Line Numbers
  1. final boolean hasReminder(String exists){
  2.         boolean ret = false;
  3.         reminderloop:
  4.         for(String rem:reminder){
  5.             if(rem.equals(exists)){
  6.                 ret = true;
  7.                 break reminderloop;
  8.             }
  9.         }
  10.         return ret;
  11.     }
I wonder what implementation did lastIndexOf method used in ArrayList?
Is that only uses the reverse value arrangement then apply the indexOf method?
Aug 3 '08 #7
JosAH
11,448 Recognized Expert MVP
I wonder what implementation did lastIndexOf method used in ArrayList?
Is that only uses the reverse value arrangement then apply the indexOf method?
If you wonder how those standard classes implemented things go to your jdk
directory and find the file src.zip. It's a zip file that contains all the source code
files for all the publicly available classes in your Java installation.

kind regards,

Jos
Aug 3 '08 #8
sukatoa
539 Contributor
Just a quick,

I've planned to implement all the necessary validations using JSP,

Now, may i know what are the disadvantages of doing such thing?
except for the passing parameters?( takes a little bit of time ) through form.....

Unlike JS, that it runs on the browser as it validates the form just in time.......
Aug 6 '08 #9
ajos
283 Contributor
Just a quick,

I've planned to implement all the necessary validations using JSP,

Now, may i know what are the disadvantages of doing such thing?
except for the passing parameters?( takes a little bit of time ) through form.....

Unlike JS, that it runs on the browser as it validates the form just in time.......
I think by validations you mean form validations? I normally do it in the client side as well as in the server side(just to be doubly sure, and thats the way it should be :)). I dont see it as a disadvantage because those are the things a web developer should do, lets say what happens when a ignorant(or any user) turns the javaScript off in the browser? I as a web developer ensure that the user doesnt skip the mandatory things that he needs to fill. I dont think that it comes down to performance, its a securuty thing for me.

regards,

ajos
Aug 6 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2543
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already started sending out the content of the page. Web content is always delivered with a few headers at the top, ending with a blank line. For example, a web page might start like this:
1
2354
by: soni29 | last post by:
Hi, I'm going to be starting a project with a friend of mine in C#, we're doing it to learn the language a little better, to get more experience with it. We've already come up with an idea of the application to build, but need advise on how to get started, to share the work? Also if there are free servers available with sourcesafe, so we can use that, and just any basic advise on getting started, how to split work. Thank you.
0
1532
by: cara_little | last post by:
Good Morning, I'm trying to get started with the Enterprise Library to evaluate it and recommend to the rest of the developers in the company. However, I'm having a heck of a time getting started and must be missing something. All of our development is completed in VB. I have installed Enterprise Library on my machine - however I can't compile the project. Is the code only available in C#? which means I have to have C# installed just to...
0
1704
by: tamdino | last post by:
Please accept my apologies if I am posting this in the wrong place. I am trying to get started using MySQL-Front and I am totally lost. Does anyone know where there is a tutorial for getting started with this interface? Thanks, Tammy
84
3950
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: Hireability Portability Flexibility The likely candidates seem to be Java, VB.Net, C, C++, C#.
6
2186
by: Jack Duijf | last post by:
Hello, I am looking for a person in The Netherlands that is willing to help me getting started with Vb.net. Please send a message to jack@aicn.nl if you can help me getting started with the Microsoft Developement Enviroment. Thanks,
1
4747
by: =?Utf-8?B?Q29kZVNsaW5nZXI=?= | last post by:
I plan to build my own 2008 Server/Hyper-V system and will not be using one of the tested Dell or HP systems from the release notes and could use some pointers as to my assumnptions and answers to a few questions. Some getting started with Hyper-V assumptions. Please tell me if I am off base here. 1. Any recent Intel quad core processor has the needed x64 architecture with hardware assisted virtualization and data execution protection...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.