• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problem in jsp !!!

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai everybody,
I m getting the problem in jsp so please help me out!!!
<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
<HTML>
<HEAD>
<TITLE>Invoice process </TITLE>
</HEAD>
<BODY>

<tr><td align=right><h2> Item Unit price Quantity SubTotal </h2></td>
</tr><br><br>
<%!
String x="0";
String y="0";
String z="0";
double t1;
double t2;
double t3;

%>
<%

x = request.getParameter("cd");
y= request.getParameter("flopy");
z = request.getParameter("cdmusic");

t1 = (Integer.parseInt(x)) * 0.50;
t2 = (Integer.parseInt(y)) * 10.99;
t3 = (Integer.parseInt(z)) * 15.50;

%>
CDR $0.50 <%= t1 %><br><br>

Disks$10.99 <%= t2 %><br><br>

Music$15.50 <%= t3 %><br>

</BODY>
</HTML>
 
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ramakrishna pydipati:
please help me out!!!


Sure. But how can you expect people to help you, when you don't tell what the problem is!?
 
ramakrishna pydipati
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai sorry about it.
it is giving null error.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think, the attributes cd, flopy & cdmusic are not set properly.
How are you calling the JSP? Straight from the browser or from a different JSP or Servlet?
 
ramakrishna pydipati
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am calling from HTML page (project6.html)
<HTML>
<HEAD>
<TITLE>Invoice</TITLE>
</HEAD>
<BODY>
<form action="project6.jsp" method="POST" >

<table align=center >
<tr><td align=right> Specify the quantity you want to buy :</td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
<tr><td align=left>CD Writer: $0.50/each</td>
<td align=left><input type=text name="cd" size=7></td>
</tr>
<tr><td align=left>Floppy Disks: $10.99/package:</td>
<td align=left><input type=text name="flopy" size=7></td>
</tr>
<tr><td align=left>Music CD: $15.50/each</td>
<td align=left><input type=text name="cdmusic" size=7></td>
</tr>
<tr><td colspan=2 align=right><input type=submit value="Submit">
<input type=reset value="Reset"></td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
</table>
</form>
</BODY>
</HTML>
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mmmm...I don't find any problem with the code. :roll:
Is it happening always or only if you leave any of the input field empty? And make sure that all the names or spelled in the same way in both JSP & HTML (for example, is it flopy in both JSP & HTML?)
Probably you can paste the entire exception.
 
ramakrishna pydipati
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
always it is giving out put as 0 in jsp page and nothing is getting printed
in html page.
this is my htmlpg:
<HTML>
<HEAD>
<TITLE>Invoice</TITLE>
</HEAD>
<BODY>
<form action="project6.jsp" method="POST" >

<table align=center >
<tr><td align=right> Specify the quantity you want to buy :</td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
<tr><td align=left>CD Writer: $0.50/each</td>
<td align=left><input type=text name="cd" size=7></td>
</tr>
<tr><td align=left>Floppy Disks: $10.99/package:</td>
<td align=left><input type=text name="flopy" size=7></td>
</tr>
<tr><td align=left>Music CD: $15.50/each</td>
<td align=left><input type=text name="cdmusic" size=7></td>
</tr>
<tr><td colspan=2 align=right><input type=submit value="Submit">
<input type=reset value="Reset"></td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
</table>
</form>
</BODY>
</HTML>
this is jsp page:
<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
<HTML>
<HEAD>
<TITLE>Invoice process </TITLE>
</HEAD>
<BODY>

<tr><td align=right><h2> Item Unit price Quantity SubTotal </h2></td>
</tr><br><br>
<%!
String x;
String y;
String z;
double t1;
double t2;
double t3;

%>
<%

x = request.getParameter("cd");
if (request.getParameter("cd")!=null)
{
x= request.getParameter("cd");}
else
{
x= "0";
}

y= request.getParameter("flopy");
if (request.getParameter("flopy")!=null)
{
y= request.getParameter("flopy");}
else
{
y= "0";
}
z = request.getParameter("cdmusic");
if (request.getParameter("cdmusic")!=null)
{
z= request.getParameter("cdmusic");}
else
{
z= "0";
}

%>

<%
t1 = (Integer.parseInt(x)) * 0.50;
t2 = (Integer.parseInt(y)) * 10.99;
t3 = (Integer.parseInt(z)) * 15.50;
%>

CDR $0.50: <%= t1 %><br><br>

Disks$10.99: <%= t2 %><br><br>

Music$15.50: <%= t3 %><br>

</BODY>
</HTML>
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nothing wrong with the code html and jsp... tried on my mc.. works well
no problems about that,
i am using Tomcat 4.0.
 
Ranch Hand
Posts: 1880
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
========
In a single page u cannotgive mor than one page directive declaration...
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In a single page u cannotgive mor than one page directive declaration...


That is not correct. There are some clauses that you cannot repeat (such as language), but you can have as many page directives as you want for the repeatable clauses such as import.
bear
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I tested your pages and currently iam using Tomcat4.1 and its working fine and i dont find any null error.
may be you need to check once again and what server are you using now.
have a nice time
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ramakrishna pydipati :
I advice you put print statement in your code to enable you know precisely which variable is throwing the null pointer exception; that will help you resolve the problem.
anselm
 
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic