Results 1 to 10 of 10
  1. #1
    gb.rashu is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Question how to solve exception in jsp?

    Hello,
    I am new to Jsp. am doing SMS application using Jsp, getting exception in the follwing code.. am not getting how to solve this error.

    can u anyone tel me solution for this? .am waiting for ue reply.:confused:





    <%@ taglib uri="/tags/struts-html" prefix="html"%>
    <%@ taglib uri="/tags/struts-bean" prefix="bean"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html:html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>SMS Application Home Page</title>
    <style type="text/css">
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    }
    .style1 {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:11px;
    }
    .headingStyle {
    color:#12447D; font-size:18px; font-weight:bold;
    }

    a:active {
    text-decoration: none;
    }
    a:link {
    text-decoration: none;
    }
    a:visited {
    text-decoration: none;
    }
    a:hover {
    text-decoration: none;
    }
    a.linkMenu {
    background-color:#999999;
    border: 2px solid;
    border-radius-topright: .5em;
    border-radius-bottomright: .5em;
    padding: .5em;
    z-index: 101;
    color:#FFFFFF;
    font-size:13px;
    font-weight:bold;
    position:fixed;
    }
    </style>

    <script language="javascript">
    function showMessagesLeft(){
    if( document.getElementById('MsgsLeft').value <= 25 ) {
    alert("Please intimate to admin \n only few messages are exist!...");
    return false;
    }
    }
    </script>

    </head>
    <body onload="showMessagesLeft();">
    <%@ page import="com.eft.globals.apps.dataaccess.DBAccess"% >
    <%@ page import="java.sql.ResultSet"%>
    <%@ page import="java.sql.SQLException"%>
    <%@ page import="java.io.*,java.net.*,java.util.StringToken izer"%>
    <%! String username="";%>
    <%
    HttpSession ses=request.getSession(true);
    username=(String)ses.getAttribute("username");
    String Designation=(String)ses.getAttribute("Designation" );
    //out.println(Designation);

    if(username!=null)
    {
    %>
    <form styleId="userCreatFrm">
    <% ses.setAttribute("username",username);
    String empMail_Id="",empPhone="";
    try{
    DBAccess dba = new DBAccess();
    String Username=dba.getSMSUsername();
    String password=dba.getSMSPassword();

    String strurl=" http://202.71.152.238/desk2web/CreditCheck.aspx?Username="+Username+"&Password="+ password+" ";
    // out.println("Url; "+strurl);
    URL url = new URL(strurl);
    HttpURLConnection connection =(HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setUseCaches(false);
    connection.connect();
    InputStream inStream = connection.getInputStream();
    BufferedReader input =
    new BufferedReader(new InputStreamReader(inStream));
    String line = "",Line1="";
    while ((line = input.readLine()) != null){
    Line1=Line1+line;
    }
    int LineLength=Line1.length();
    String MessagesLeft=Line1.substring(7,12);
    int TotlMsgs = Integer.parseInt(MessagesLeft);
    String MessagesUsed=Line1.substring(20,LineLength);
    // out.println("Total Messages are "+TotlMsgs);
    // out.println("<br>Line: "+MessagesUsed);
    StringTokenizer stoken = new StringTokenizer(MessagesUsed,"'");
    int MsgsUsed=Integer.parseInt(stoken.nextToken());
    // out.println("<br> Messages Used: "+MsgsUsed);
    long MsgsPresent=TotlMsgs-MsgsUsed;
    // out.println("<br>Messages Left: "+MsgsPresent);
    %>
    <input type="hidden" name="MsgsLeft" id="MsgsLeft" value="<%=MsgsPresent%>"/>

    <html:hidden property="loginUserName" value="<%=username%>"/>
    <table width="780" align="center" bgcolor="#E8E8E8" class="style1" cellpadding="0">
    <tr>
    <td colspan="6" valign="top"><img src="/efort/gui/images/SMS_Application1-.jpg" width="780" height="150" border="0"/></td>
    </tr>
    <tr>
    <td width="766" height="412" valign="top"> <!-- ==============Start Inner Table ================ -->
    <table width="760" align="center" cellpadding="2">
    <tr align="right" height="5%">
    <td colspan="3" align="right">
    <a href="/efort/gui/jsp/Efort_New_Home.jsp"><b>Home</b></a>&nbsp;
    <a href="/efort/gui/jsp/Logout.jsp"><b>Logout</b></a></td>
    </tr>
    <tr align="center">
    <td colspan="3" align="center"class="headingStyle">Welcome to SMS Applications </td>
    </tr>
    <tr> <td colspan="3" align="right"><b><% out.println("Messages: "+MsgsUsed+" Used, "+MsgsPresent+" Left ");%></b></td> </tr>
    <tr> <td colspan="3" valign="middle">&nbsp;</td> </tr>
    <%
    if(username.equals("admin")){ %> <!-------------- Link WIll NOt Display for recruiters" -->
    <tr> <td height="42" colspan="4" align="center">
    <a href="/efort/gui/jsp/SMS/UserCreatedList.jsp" class="linkMenu">&nbsp;&nbsp;UserCreation&nbsp;&nb sp;&nbsp;</a>
    </td>
    </tr>
    <% }else{
    try{

    dba.connect();
    String query="select usr.emp_MailId,usr.emp_phone from user_created_sms as usr where usr.emp_id='"+username+"'";
    ResultSet rs =dba.executeQuery(query);
    if(rs.next()){
    empMail_Id=rs.getString("usr.emp_MailId");
    empPhone=rs.getString("usr.emp_phone");
    ses.setAttribute("empMail_Id",empMail_Id); // set the login user email id...
    ses.setAttribute("empPhone",empPhone); // set the login user phone number...
    %>
    <tr> <td colspan="4" height="42" align="center">
    <a href="/efort/gui/jsp/SMS/SMS_Sending.jsp" class="linkMenu">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;&nbsp;&nbsp;&nbsp;SMS&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;</a></td>
    </tr>

    <tr> <td colspan="4" height="40" align="center">
    <a href="/efort/gui/jsp/SMS/AddressBookPage.jsp" class="linkMenu">&nbsp;&nbsp;Address Book&nbsp;&nbsp;&nbsp;</a></td>
    </tr>

    <tr> <td colspan="4" height="36" align="center">
    <a href="/efort/gui/jsp/SMS/SMS_TrackingPage.jsp" class="linkMenu">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;Tracker&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;</a></td>
    </tr>

    <tr> <td colspan="4" height="38" align="center">
    <a href="/efort/gui/jsp/SMS/VerificationPhoneListPage.jsp" class="linkMenu">&nbsp;Verification List&nbsp;</a></td>
    </tr>
    <tr>
    <td colspan="4" height="39" align="center">
    <a href="/efort/gui/jsp/SMS/SMS_DeletedInfoList.jsp" class="linkMenu">Deleted SMS List</a></td>
    </tr>
    <tr>
    <td colspan="4" height="39" align="center">
    <a href="/efort/gui/jsp/SMS/SMS_UsersDeletedInfoList.jsp" class="linkMenu">Deleted Phone Numbers List</a></td>
    </tr>
    <%} else{ %>
    <tr align="center">
    <th colspan="3" align="center"><font color="#3366FF">You are not able to access this application, Please contact administration</font> </th>
    </tr>
    <%
    } // end of else part...
    }catch(SQLException se){
    System.out.println("Error: "+se);
    } // end of catch block...

    } // end of else part other than admin condition...

    %>
    <tr> <td colspan="4" align="center">&nbsp;</td> </tr>
    </table>
    <!-- ==============End Inner Table ================ -->
    </td>
    </tr>
    <tr> <td colspan="4" height="18"align="center" bgcolor="#CBD49E">CopyRight @2007</td> </tr>
    </table>
    <% }
    catch(java.net.ConnectException e){
    out.println("NO Internet available"+e);
    }
    %>
    </form>
    <% } else{ out.println("<br><br><br><center><h1>Access denied <br>Please login....<a href='/efort/gui/jsp/Logout.jsp'>Login</a></h1>");
    }%>
    </body>
    </html:html>

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    gb.rashu is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Default

    Hello,
    this is the Error Message .



    message

    description The server encountered an internal error () that prevented it from fulfilling this request.

    exception

    org.apache.jasper.JasperException: For input string: "PE ht"
    org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.owasp.filters.filter.doFilter(filter.java:104)


    root cause

    java.lang.NumberFormatException: For input string: "PE ht"
    java.lang.NumberFormatException.forInputString(Num berFormatException.java:48)
    java.lang.Integer.parseInt(Integer.java:447)
    java.lang.Integer.parseInt(Integer.java:497)
    org.apache.jsp.gui.jsp.SMS.SMS_005fHomePage_jsp._j spService(org.apache.jsp.gui.jsp.SMS.SMS_005fHomeP age_jsp:176)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:332)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
    org.owasp.filters.filter.doFilter(filter.java:104)


    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


    --------------------------------------------------------------------------------

    Apache Tomcat/5.0.28

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Did you read the compete error message.

    java.lang.NumberFormatException: For input string: "PE ht"
    java.lang.NumberFormatException.forInputString(Num berFormatException.java:48)

  5. #5
    gb.rashu is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Did you read the compete error message.

    Thanks for the response.
    Yes i read complete error message. but it is Jsp file .it is number format exception. i imported
    <%@ page import="com.eft.globals.apps.dataaccess.DBAccess"% > java file. first time it works now it is throwing exception.. how to solve this?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Somehow an invalid number retrieve from the database. Easiest way I guess is to check on the database data fields. Or else you've debug the code separately, bit of work to do then.

  7. #7
    gb.rashu is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Default

    Thank You.. i will try once :-)

  8. #8
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,965
    Rep Power
    19

    Default

    And now for my usual entry into these things...don't mix display and business logic. That is the JSP page should only be about displaying stuff handed to it via a servlet which does the actual work. In your case the servlet would do the db work, leaving the JSP to simply access the processed data and not ResultSets or Connections or Statements.

  9. #9
    gb.rashu is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Default

    Thank You. i did copy and paste same file into the new file . Now it is Executing Successfully.
    Thank You to all.. Ur Tips r helps a lot :-):-)

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Tolls View Post
    And now for my usual entry into these things...don't mix display and business logic. That is the JSP page should only be about displaying stuff handed to it via a servlet which does the actual work. In your case the servlet would do the db work, leaving the JSP to simply access the processed data and not ResultSets or Connections or Statements.
    That's the advantage of having a well define design. All have to do with OO, isn't it.

Similar Threads

  1. How to solve this "Fixtures code" error exception?
    By makerror in forum New To Java
    Replies: 4
    Last Post: 12-02-2009, 02:45 AM
  2. Plz solve this....
    By theone3nu in forum Java 2D
    Replies: 3
    Last Post: 01-08-2009, 05:01 PM
  3. Plz solve this....
    By theone3nu in forum New To Java
    Replies: 9
    Last Post: 12-23-2008, 09:42 AM
  4. how to solve transformer exception
    By java_arc in forum Advanced Java
    Replies: 1
    Last Post: 04-19-2008, 12:46 PM
  5. Replies: 1
    Last Post: 03-08-2008, 06:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •