Hi,
I get org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "f"
root cause
in the below code -
-
String f= request.getParameter("f");
-
int from = Integer.parseInt("f");
-
-
Thank You
34 5150
Take the quotes off on line 3. You're trying to parse the variable f, not the string "f".
still the same error
org.apache.jasper.JasperException: java.lang.NumberFormatException: null
seems like f is null
so why it does not read request.getParameter("f") in doGet
Either the name of the variable you're trying to get is wrong or it's not being passed.
i have it in a link - out.println("<a href=\"inbox.jsp?k=-&f="+f+">")
it reads k but not f
What is k? Why is it just a dash?
You may want to also check the value of f on the client side.
if k is "-", it means minus 15 records
if k is "+", it means plus 15 records
In doGet i have an error. k=null and f=null.
Why it does not take these variables from url?
Just a thought: Shouldn't that code be in the doPost method rather than doGet? Maybe that would explain the null values.
doPost works when i send the data from a form but when i want to read data from url it does not work
OK, next idea: - out.println("<a href=\"inbox.jsp?k=-&f="+f+">")
This might be missing the end of the href quote: - out.println("<a href=\"inbox.jsp?k=-&f="+f+"\">")
Just to make sure, I'd check how the link is rendered in the resulting HTML.
http://localhost:8080/CCC/c.jsp?k=+&f=0
not working :( -
public void doGet(HttpServletRequest request, HttpServletResponse response)
-
throws ServletException, IOException {
-
String k=request.getParameter("k");
-
-
String f= request.getParameter("f");
-
-
-
int from = Integer.parseInt(f);
-
still k and f = null
What does the HTML on the client side look like?
- response.setContentType("text/html");
-
PrintWriter out = response.getWriter();
-
out.println("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"css.css\"/><title>HRMailer</title></head><body>");
-
out.println("<table width=\"900\">");
-
out.println("<tr><td>");
-
if(f>=15) {
-
out.println("<a href=\"inbox.jsp?k=-&f="+f+"\">");
-
-
out.println("<< prev");
-
-
out.println("</a>");
-
}
-
out.println("<a href=\"inbox.jsp?k=+&f="+f+"\">"); out.println("next >>");
-
out.println("</a>");
-
-
out.println("</td></tr></table");
-
-
out.println("<table width=\"150\">");
-
out.println("<tr>");
-
out.println("<td valign=\"top\"> ");
-
out.println("<table align=\"left\">");
-
out.println("<tr><td width=\"150px\" aling=\"left\">");
-
out.println("<a href=\"inbox.jsp\">Inbox</a></td></tr>");
-
out.println("<tr><td><a href=\"sent.jsp\">sent</a></td></tr>");
-
out.println("<tr><td><a href=\"drafts.jsp\">drafts</a></td></tr>");
-
out.println("<tr><td><a href=\"trash.jsp\">Trash</a></td></tr>");
-
out.println("</table>");
-
-
-
out.println("<table cols=\"5\" alin=\"left\"><form action=\"do.jsp\" method=\"post\">");
-
out.println("<tr class=\"span1rstRow\">");
-
out.println("<td>");
-
out.println("c");
-
out.println("</td>");
-
out.println("<td>d?</td>");
-
out.println("<td>");
-
out.println("Subject:");
-
out.println("</td>");
-
out.println("<td>");
-
out.println("From:");
-
out.println("</td>");
-
out.println("<td>");
-
out.println("Date:");
-
out.println("</td>");
-
out.println("</tr");
-
HttpSession session = request.getSession();
-
-
Connect connectToImap = new Connect();
-
connectToImap.login((String)session.getAttribute("username"),(String)session.getAttribute("password"));
-
-
-
Message[] messages = connectToImap.fetchMails();
-
System.out.println("connect.fetchMails();");
-
System.out.println(request.getParameter("k"));
-
-
-
try{
-
for (int i=f; i < t ;i++){
-
-
Message msg = messages[i];
-
if (msg.isSet(Flags.Flag.DELETED))
-
{ continue; } else {
-
out.println("<tr>");
-
out.println("<td>");
-
out.println("<input type=\"checkbox\" name=\"do\" value="+i+">");
-
out.println("</td>");
-
out.println("<td>");
-
out.println("d");
-
out.println("</td>");
-
out.println("<a href=open.jsp?i="+i+">");
-
-
String subject = msg.getSubject();
-
-
out.println("<td>");
-
out.println(subject);
-
out.println("</td>");
-
out.println("<td>");
-
out.println(InternetAddress.toString(messages[i].getFrom()));
-
out.println("</td>");
-
-
-
out.println("<td>");
-
-
out.println(messages[i].getReceivedDate());
-
out.println("</td");
-
out.println("</tr> ");
-
out.println("</a>");
-
} }
-
out.println("</table></form>");
-
out.println("</td>");
-
out.println(" </tr>");
-
out.println("</table>");
-
out.println("<body></html>");
-
out.close();
-
} catch (MessagingException e){
-
e.printStackTrace();
-
}
-
}
-
That's the server side. I'm looking for the client side.
- <html><head><link rel="stylesheet" type="text/css" href="css.css"/><title>HRMailer</title></head><body>
-
<table width="900">
-
<tr><td>
-
<a href="inbox.jsp?k=+&f=0">
-
next >>
-
</a>
-
Maybe I'm wrong, but using "+" as a value for variable k can be the reason that k and f have no values.
How?
You are using "+" directly in your URL when creating it with out.println. ( For example you print out href="inbox.jsp?k=+&f=12") But you should use the hex-code string "%2B" for it instead "+". Because a plus-sign is converted to space when submitted to the server. When there is some redirection or other double-parsing of the URL, the space determines the end of the URL, therefore all characters following this space are cut off. (In your case "inbox.jsp?k= &f=12" changes to "inbox.jsp?k="). The effect is that both variable k and f are empty.
with out.println("<a href=\"inbox.jsp?k=+&f=f\">");
i get
java.lang.IllegalStateException: isHexDigit
- <html><head><link rel="stylesheet" type="text/css" href="css.css"/><title>HRMailer</title></head><body>
-
<table width="900">
-
<tr><td>
-
<a href="inbox.jsp?k=+&f=0">
-
next >>
-
</a>
-
http://localhost:8080/CCCC/cccc.jsp?k=+&f=0
org.apache.jasper.JasperException: java.lang.NumberFormatException: null
- <%
-
-
CCC ccc = new CCC();
-
ccc.doGet(request, response);
-
-
%>
if i change k=+ to k=1 it works
how do i quote in out.println the plus sign?
out.println("<a href=\"inbox.jsp?k=+&f="+f+"\">");
String k=request.getParameter("k"); is not working neither
how do i quote in out.println the plus sign?
Did you have difficulties understanding my previous reply? (if yes, don't hesitate to ask)
I told you to use the hex value "%2B" for it. That means: - out.println("<a href=\"inbox.jsp?k=%2B&f="+f+"\">");
if i change k=+ to k=1 it works
That means I was right and the improper coding of the plus-sign caused it the way I described.
You should also be careful in coding other characters. Like space should be coded as "+" or as "%20".
Plase try it again and tell me if it works now.
out.println("<a href=\"inbox.jsp?k=%2B&f="+f+"\">");
i get java.lang.IllegalStateException: isHexDigit
Are you using Glassfish4 ? Then most likely it is a bug, try to download the patch for glassfish.
Or:
Try using "%31" (which is digit "1") instead of "%2B". I just want to know if hex-digit parsing is a common problem for your Server.
Another try: use single quotation marks instead of double quotation marks. That means, use: - out.println("<a href='inbox.jsp?k=%2B&f="+f+"'>");
I get blank page with - out.println("<a href='inbox.jsp?k=%2B&f="+f+"'>");
I use GlassFish 4
And what about the other 2 possibilities?
Did you apply the glassfish-patch?
Did using "%31" work?
Another thing that would help greatly:
You are generating HTML that is send to the client browser. So just right-click in the browser page and select "view source" in the popup-menu. Locate the generated code that contains the "<a href..." from above and paste it here in this forum thread for further analysis.
Then we can decide if getting a blank page is one step to the solution and we solved the first error (hex-parsing). There may be a second error following the first one, like the link works, but the following page "inbox.jsp" contains an error somewhere, resulting in a blank page returned.
when i use %31 i get blank page using - out.println("<a href='inbox.jsp?k=%2B&f="+f+"'>");
also generates a blank page
Did you apply the glassfish-patch?
Can you please quote the HTML here?
What about the blank page, can you quote its HTML here, too?
When you get the blank page, then was it going to inbox.jsp before, or it went somewehre else? That means, if you insert a System.out.print statement inside inbox.jsp right at the beginning, was something printed?
with - String k=request.getParameter("k");System.out.println("k="+k);
i get in output k=+
with - String k=request.getParameter("k");
-
String f=request.getParameter("f");
-
-
System.out.println("k="+k);
-
System.out.println("f="+f);
i get k=+ and f=0 what is correct
now i have to work on doGet :)
Thank You
how do i compare %2B
?? - if(k.contentEquals("%2B")){
???
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joe |
last post by:
Hi,
I am trying to connect to a MySQL database through a Java Servlet. I
think I have correctly installed Tomcat 4.1.30 and the MySQL Database
along with ConnectorJ. I am getting a...
|
by: satyakarvvk |
last post by:
Hi everybody!
Please help me to overcome below runtime exception.
Actually it is a simple program on basics.
I want to print odd nos upto which the user asks and after printing the task,...
|
by: soty |
last post by:
HI
i wrote a code to validate cash for a vending machine.... the problem am having is dat dat my code failed to validate any ammount.
please help!!!!
the code is below
|
by: smileyme74 |
last post by:
Every time I enter for example 1 mile, I get the error.
/**
* This program will convert measurements expressed in inches,
* feet, yards, or miles into each of the possible units of
*...
|
by: prasanna ganesh |
last post by:
why i'm getting lang.string.NumberFormatException for input string ""please help me to find solution
|
by: om anand giri |
last post by:
Hello to all,
I have a problem about NumberFormatException and i m very sad because i m not able to solve this.
So please help.
The code is----------
<code>
<%@page...
|
by: AnandhaMurugan |
last post by:
I got a numberformatException when i convert from string to decimal how to resolve it
java.lang.NumberFormatException
at java.math.BigDecimal.<init>(BigDecimal.java:455)
at...
|
by: Ronak U |
last post by:
import java.io.*;
class ShellSort
{
static void shSort(int a)
{
int i,k,x,width;
width=a.length/2;
while(width>=1)
{
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
| |