GetParameter() null value

Hi all,
We are having a problem using the request.getParameter(String) method. We are using the method to define an argument for a Java Webstart (jnlp mime type) file we are creating with jsp. Other arguments have been successfully created using the request.getServerName() and request.getRequestURI() methods. The getParameter() return value looks fine if printed back to HTML. The jsp file creating the jnlp file is called using an HREF created inside another jsp file as follows:
<a href="xmlfetch.jsp?filename=mti.xml""></a>
The param value for filename in each HREF is filled using an String array entry (i.e. +names).
The xmlfetch.jsp file uses StringBuffers to capture/store the servername, uri and param data as follows:
StringBuffer svrname = new StringBuffer();
svrname.append(request.getServerName());
StringBuffer requri = new StringBuffer();
requri.append(request.getRequestURI());
StringBuffer fname = new StringBuffer();
fname.append(request.getParameter("filename"));
All 3 variables look ok if dumped in html as follows:
out.println("svrname=" +svrname);
out.println("requri=" +requri);
out.println("fname=" +fname);
But only the param value is null when the variables are passed as arguments in the jnlp stream as follows:
<argument><%=svrname.toString()%></argument>
<argument><%=requri.toString()%></argument>
<argument><%=fname.toString()%></argument>
So the question is ... why do the parameter values evaluate to non null when dumped to html but become null when used as an argument for jnlp? AND what is the difference between the strings returned by the 3 request methods we are using as arguments (i.e. why do 2/3 work?).
ANY HELP APPRECIATED:)
Greg Hock
Software Engr
Northrop Grumman Corp.
(321) 726-7758
[email protected]

I have tried the parameter specification both with and without quotes but either case results in null value for argument going into the Java Webstart (.jnlp) file that I create in the second jsp file (xmlfetch.jsp). What I don't understand is why the parameter looks correct when sent out.println() but is null when not printed and only used for the jnlp app argument. Both the other variables assigned using request.getXXX() methods are ok as arguments...only the parameters passed from the first jsp page (mtiquery.jsp) to the second jsp page (xmlfetch.jsp) become null when used as the jnlp argument.
Anyone ... please help. :)
Here is the code for the first jsp page. This page creates a table of filenames each of which has a href link to the second jsp page and passes it's filename as the parameter.
<%@ page
language="java"
import="java.util.*,java.text.*,java.io.*,javax.swing.filechooser.FileFilter"
%>
<html>
<title>MTIX MTI Query Tool</title>
<body>
<p>
<center>
<h1>JSP MTI QueryTest</h1><br>
<jsp:include page="copyright.jsp" flush="true"/>
<br>
<%=(new java.util.Date())%>
<%
String startPath = "../webapps/ATServlets/data/mti";
File myDir = new File(startPath);
String myPath = myDir.getCanonicalPath();
out.println("<br><br><br>Results of Query Path: <br>" myPath "<br><br>");
String[] filelist = myDir.list();
out.println("<br>");
out.println("<center>");
out.println("<table BORDER COLS=1 width=400>");
String urlPath = null;
String hrefPath = null;
for (int i=0; i<filelist.length; i++)
urlPath = new String("\"http://judy:8080/ATServlets/jsp/xmlfetch.jsp?filename="+filelist[i]+ "\"");
hrefPath = new String("<a href=" urlPath ">");
out.println("<tr><td><center>");
out.println(hrefPath + filelist[i] + "</a>");
out.println("</center></td></tr>");
out.println("</table>");
out.println("</center>");
%>
</center>
</body>
</html>
This first page resulted in source as follows:
NOTICE that the second jsp page is the HREF and I am using "filename" as the parameter key and the value is assigned (without quotes) to be the filelist entry.
<html>
<title>MTIX MTI Query Tool</title>
<body>
<p>
<center>
<h1>JSP MTI QueryTest</h1><br>
<html>
<head>
<title></title>
</head>
<body>
<p>(c) 1999,2000,2001 Northrop-Grumman All Rights Reserved </p>
</body>
</html>
<br>
Wed Aug 08 10:01:34 EDT 2001
<br><br><br>Results of Query Path: <br>/opt/mtix/data/mti<br><br>
<br>
<center>
<table BORDER COLS=1 width=400>
<tr><td><center>
MtiOutput.xml
</center></td></tr>
<tr><td><center>
KoreaMTI.xml
</center></td></tr>
<tr><td><center>
testMti.xml
</center></td></tr>
<tr><td><center>
testMti2.xml
</center></td></tr>
<tr><td><center>
testMti4.xml
</center></td></tr>
</table>
</center>
</center>
</body>
</html>
OK Now here is the second jsp file (xmlfetch.jsp) that is fired up after the table selection. This file creates a stream to the Java Webstart plugin and tries to use the passed parameter as 1 of 3 arguments to the application (see last few lines). The variable fname is used to hold the contents of the getParameter() method.
<%@ page
contentType="application/x-java-jnlp-file"
info="myjnlp"
import="java.lang.*,java.text.*,java.io.*"
%>
<%
StringBuffer fname = new StringBuffer();
fname.append(request.getParameter("filename"));
//fname.append("MtiOutput.xml");
//out.println("the fname var = " +fname);
StringBuffer cBase = new StringBuffer();
cBase.append(!request.isSecure() ? "http://" : "https://");
cBase.append(request.getServerName());
if(request.getServerPort() != (request.isSecure() ? 80 : 443))
cBase.append(':');
cBase.append(request.getServerPort());
StringBuffer httpref = new StringBuffer();
httpref = cBase;
httpref.append(request.getRequestURI());
StringBuffer cBase2 = new StringBuffer();
cBase2.append(!request.isSecure() ? "http://" : "https://");
cBase2.append(request.getServerName());
if(request.getServerPort() != (request.isSecure() ? 80 : 443))
cBase2.append(':');
cBase2.append("80");
cBase2.append('/');
cBase2.append("ATJava");
cBase2.append('/');
%>
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for downloading xml from servlet -->
<jnlp
spec="1.0"
codebase="<%=cBase2.toString()%>"
href="<%=httpref.toString()%>">
<information>
<title>Catalog Download Application</title>
<vendor>Northrop Grumman, Inc.</vendor>
<homepage href="ATJava.init/documents/index.html"/>
<description>XML Catalog Download Application>
<description kind="short">A demo.</description>
<icon href="ATJava.init/images/tomcat.gif"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.2" initial-heap-size="16m" max-heap-size="512m"/>
<jar href="ATJava.build/ATJava.jars/ATSignedRuntime.jar" download="eager"/>
</resources>
<resources>
<j2se version="1.3" initial-heap-size="16m" max-heap-size="512m"/>
<jar href="ATJava.build/ATJava.jars/ATSignedRuntime.jar" download="eager"/>
</resources>
<application-desc main-class="mtix.XMLFetch">
<argument><%=fname.toString()%></argument>
<argument><%=cBase2.toString()%></argument>
<argument><%=httpref.toString()%></argument>
</application-desc>
</jnlp>
Please HELP/COMMENT if you can.... Gregg

Similar Messages

  • GetParameter()==NULL and memory

    Hi everybody !
    I'm creating a web site where users will be able to plot data from a database.
    So, I've an HTML code which call a PHP one which himself get data from database and create an JAVA applet on the following model :
    echo "<APPLET\n";
    echo "<PARAM NAME=\"valeur\" VALUE=\"".$string."\">\n";
    echo "</APPLET>\n";where $string is like "time1%data1@time2%data2@...."
    Then I get this string value in the JAVA applet with :
    String[] res = getParameter("valeur").split("@");But for too huge data size the getParameter return a NULL value as PHP hadn't create the associated param value.
    Does someone have an idea to explain such behaviour ?
    Thanks !

    nodules wrote:
    ..in that case I'll have to execute the query in the applet, and so, on the client side which is not really safe, isn't it ?In my suggestion I think the answer is 'yes'.
    .. Since I'll have to export password, etc on the client side ...Which is why ejp (who knows far more about remote access to DBs) added..
    ..or have it perform an HTTP request of its own ..Which I think means to have the applet connect to (for example) a servlet that does the query. The servlet would not expose the password or location of the database, and might do other checks (like that the user is actually allowed to delete every record). ;)

  • Geting null values from request

    hi!
    i m producing this code through out.println() method in my page and then using java script
    i am submiting this page to another page
    <td width="56%"><textarea name="question_no_1"></textarea></td>
    <input name="question_no_1_radio1" type="radio" value="radio"></td>
    <td width="59%"> <textarea name="question_no_1_ans1"></textarea></td>
    <input type="radio" name="question_no_1_radio2" value="radio"></td>
    <td><textarea name="question_no_1_ans2"></textarea></td>
    <input type="radio" name="question_no_1_radio3" value="radio"></td>
    <td><textarea name="question_no_1_ans3"></textarea></td>
    <input name="question_no_1_radio4" type="radio" value="radio"></td>
    <td><textarea name="question_no_1_ans4"></textarea></td>
    but when i submit it to the other page and try to retrieve value of parameter "question_no_1"
    through the bellow statement it shows a null value but i have given a value previously by
    typing a question in it
    System.out.println("the Body Of The First Question Is "+request.getParameter("question_no_1"));
    can anybody help me what is going on here.
    also if i try to normaly submit first page (ie <form="form1" method="post" action="other_jsp_page.jsp"> ) then the statement in the next page gives me the correct value but
    i have to submit the first paper through java script.
    if u want to see full detail of my code then go to the following link
    http://forum.java.sun.com/thread.jsp?thread=309254&forum=45&message=1237097
    thanx in advance

    OK, your problem is that you are not submmiting the values to the other page. When you do the
    --> document.forms[0].submit();
    in JavaScript, the form has to action defined
    --> <form name="form1" method="" action="">
    So, the page does nothing. The line following the submit just changes the location of the page, IT DOES NOT POST the values.
    One solutions is the following:
    1.- define an action for your form:
    <form name="form1" method="POST" action="'save_paper.jsp">
    2.- Then create a JavaScript function that validates the fields and simply return "true" if the form is correct, and false if there is a problem (just a little modification of the one you have).
    3.- Then modify your submit button:
    Instead of:
    <input type="button" name="Save" value="Save" onClick="validateField()">
    Try:
    <input type="SUBMIT" value="Save" onclick="validateField();">

  • Not to display the null values from data base

    Hiiii.
    In a jsp file i have ten check boxes.The jsp file is mapped to a servlet file for parameter requesting and to
    store it in DB.
    The unchecked box values has null values.All the values are store in a Mysql DB table.
    Again i have to display it in a jsp page from table.
    The problem am facing was,how can i display only the values in a row.it must not display the null values and the crresponding column name.
    Or any other way is their like below
    How i can retrieve only the selected check boxes from tht jsp file.and store in backend.
    Thanks in Advance
    regards,
    satheesh kannan

    Here is a rough example that may give you some ideas:
    On the JSP page:
    <%if(myData.getFirstName()!=null){%>
    Your First Name'
    <input type="text" name="firstName" value="<%=myData.getFirstName()%>">
    <%}%>
    In the servlet:
    String firstName= request.getParameter("firstName");
    if(firstName!=null){
    //write it to the database
    }

  • Null values passed into the servlet

    Hi all,
    I keep getting null values for all the params that I pass into the servlet i.e. sqltype, producttype, process, instance etc....I have attempted to print some of them out on the screen but I keep getting the 'NullPointerException' error message...can anyone tell me what it is that I have down wrong in the below code?
    If I run the servlet with method calls that have hardcoded arguments in them it works but not when I pass in the params from the URL...I am absolutley puzzled!
    Help!
    package blotter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Date;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.db.util.WriteToLogFile;
    import blotter.cache.*;
    Servlet to extract an object that has already been placed
    in the cache by GetBondPrices servlet from the cache.
    public class ExtractSecurityObject extends HttpServlet
         String sqlType = "";
         String productType = "";
         String instance = "";
         String process = "";
         String asOfDate = "";
         String currencyCode = "";
         String curveId = "";
         String results = "";
         private String debug;
    private PrintWriter out;
         private WriteToLogFile logFile;
         // called when servlet first initialised
         public void init(ServletConfig config) throws ServletException
              super.init(config);
         // method called for each get request
         public void doGet( HttpServletRequest request, HttpServletResponse response )
                   throws ServletException, IOException
              String toWrite = " ";
    // Get the object identifier from the parameters passed in
              sqlType = request.getParameter("sqltype");
    productType = request.getParameter("producttype").toUpperCase();
              instance = request.getParameter("instance");
              process = request.getParameter("process");
              asOfDate = request.getParameter("asofdate");
              curveId = request.getParameter("curveid");
              currencyCode = request.getParameter("ccy").toUpperCase();
              out.println(currencyCode);
              if ( request.getParameter("debug") !=null)
                   debug = request.getParameter("debug");
              else
                   debug ="";
              // set the mime type to html
    response.setContentType( "text/html" );
    out = response.getWriter();
    out.println("<HTML>");
              try
              // write some parameters to a log file
              toWrite = toWrite + "<li>" + getServletInfo() + " at " + new Date() + " " + sqlType + " " +
                        productType + " " + instance + " " + process + " " + asOfDate + " " + curveId + " " +
                        currencyCode;
         CachedObject o1 = (CachedObject)CacheManager.getCache("EB_" + currencyCode + productType + asOfDate);
    if(o1 == null){
              CacheSecurityObject cso = new CacheSecurityObject();
                   if((request.getParameter("sqltype") == null) && (request.getParameter("instance") != null)){
    results = (String)cso.putSecurityinCache(null, request.getParameter("producttype"), request.getParameter("instance"), request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    //results = (String)cso.putSecurityinCache(null, "yc", "frafu", "official", "20011105", "baceod", "sek");
    out.println(results);
                   } else {
    //results = (String)cso.putSecurityinCache("bondtypes", "bond", null, "official", "20011105", "baceod", "eur");
    results = (String)cso.putSecurityinCache(request.getParameter("sqltype"), request.getParameter("producttype"), null, request.getParameter("process"), request.getParameter("asOfDate"), request.getParameter("curveId"), request.getParameter("currencyCode"));
    out.println(results);
              else{
                   out.println(((String)o1.object).toString());
    // general catch for all exceptions
              catch(Exception exception)
                   out.println( "Exception: The item that you requested was not found in the cache" + "<BR>" );
                   toWrite = toWrite + "Exception : " + exception.getMessage() + "\n" ;
              finally
    // write to logfile
              logFile = new WriteToLogFile();
              logFile.setSourceDirName("blotter");
              logFile.setQuery(request.getQueryString());
              logFile.setServletPath(request.getServletPath());
              if (toWrite!=null)
              logFile.writeLog(getServletInfo(),toWrite);
    out.println("</HTML>");
              out.close();
         // need the class name for log file
         public String getServletInfo()
         return this.getClass().getName();
    }

    That section of the code references a cache to extract an item that has been requested by the user. If the item is not in the cache i.e. if(o1 == null) then it will call a class that generates that object and places that object into the cache. The second time the user makes the same call then they will be handed a cached copy of that object which is aimed to make the whole servlet call faster.
    That section of the code works fine coz I have tested that separately. It is the reading in of the arguments that is causing the problem.

  • How to eliminate explicit "null" values

    Hello,
    I am having a problem in eliminating the explicit "null" values while retrieving them from the database.
    Here is my problem as follows,
    For the optional fields in a form i am explicitly entering "null" as value or else it is throwing null pointer exception in linux. While i am trying to display the values existing in a table it is displaying fine when i use this condition
    if(varialble.equals("null") ||varialble.equals("") || variable.equals(null))
    varialble = "";
    else
    out.println(variable)
    But when i use the same for the values i retrieve from the view it is displaying "Null" for the explicit "null" values and null from implicit null values.
    Please help me out how to remove the explicit null values. It would be great help if somebody replies me at the earliest.
    Thanks in advance
    daya

    the following is the code which i am using to retrieve values.
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import StrChk.*;
    public class DataSearch extends HttpServlet
         Connection con=null;
         Statement st=null;
         ResultSet rs=null;
         ResultSetMetaData rsmd=null;
         PrintWriter out=null;
         public void doPost(HttpServletRequest req, HttpServletResponse res)
         throws IOException,ServletException
              String key;
              String sql;
              res.setContentType("text/html");
              out = res.getWriter();
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   con = DriverManager.getConnection("jdbc:odbc:daya","daya","daya");
                   st = con.createStatement();
              catch(Exception e)
                   System.out.println("Error Accessing DataBase:"+e);
              key = req.getParameter("key");
    //          Search(str1.retString(key));
              Search(key);
         public void Search(String key)
              int res=0;
              boolean flag=true,found=false;
              StringTokenizer strt = new StringTokenizer(key, " ");
              String sql;
              String str1,str2;
              int i=0;
    int count = strt.countTokens();
    String keywords[] = new String[count+1];
              keywords=key;
              i++;
              if(count > 1)
         count++;
                   while(strt.hasMoreTokens())
                   keywords[i] = strt.nextToken();
                        i++;
              out.println("<html><title>DataSearch</title>");
              out.println("<script>");
              out.println("function myclose(){ self.close(); } ");
              out.println("</script><body>");
              for(i=0; i<count && flag==true; i++)
                   try
              /* sql = "select ";
                   sql += " nvl(\"Topic Title\",' '), ";
                   sql += " nvl(\"Name\",' '), ";
                   sql += " nvl(\"Title\",' '), ";
                   sql += " nvl(\"Affiliation\",' '), ";
                   sql += " nvl(\"Street Name\",' '), ";
                   sql += " nvl(\"City\",' '), ";
                   sql += " nvl(\"State\",' '), ";
                   sql += " nvl(\"Country\",' '), ";
                   sql += " nvl(\"Zip Code\",' '), ";
                   sql += " nvl(\"Phone\",' '), ";
                   sql += " nvl(\"Fax\",' '), ";
                   sql += " nvl(\"eMail\",' '), ";
                   sql += " nvl(\"Web Site\",' ') ";
                   sql += " from SEARCHVWUSERDET where ";
                   sql += " lower(\"Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Title\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Affiliation\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Street Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"City\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"State\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Country\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"eMail\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Web Site\") like " + "lower('%" + keywords[i] + "%')";*/
                   sql = "select ";
                   sql += " nvl(\"Name\",' '), ";
                   sql += " nvl(\"Title\",' '), ";
                   sql += " nvl(\"Affiliation\",' '), ";
                   sql += " nvl(\"Street Name\",' '), ";
                   sql += " nvl(\"City\",' '), ";
                   sql += " nvl(\"State\",' '), ";
                   sql += " nvl(\"Country\",' '), ";
                   sql += " nvl(\"Zip Code\",' '), ";
                   sql += " nvl(\"Phone\",' '), ";
                   sql += " nvl(\"Fax\",' '), ";
                   sql += " nvl(\"eMail\",' '), ";
                   sql += " nvl(\"Web Site\",' '), ";
                   sql += " nvl(\"Key Words\",' ') ";
                   sql += " from searchcombi where ";
                   sql += " lower(\"Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Title\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Affiliation\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Street Name\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"City\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"State\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Country\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"eMail\") like " + "lower('%" + keywords[i] + "%') or ";
                   sql += " lower(\"Web Site\") like " + "lower('%" + keywords[i] + "%') or";
                   sql += " lower(\"Key Words\") like " + "lower('%" + keywords[i] + "%')";
                   sql += " order by \"Name\" ";
                   rs = st.executeQuery(sql);
                   //out.println(sql);
                   if(rs.next())
                        if(i == 0)
                             flag=false;
                        found=true;
                        res=0;
                   do
                        res++;
                   }while(rs.next());
                   out.println(res++);
                   out.println("<center><font color=#ff9999 face=\"verdana, geneva, arial, sans-serif\" size=2><b>Searched for \""+ keywords[i]+"\", ");
                   out.println("Total Matches found : "+res+"</center><br>");
                   rs = st.executeQuery(sql);
                   while(rs.next())
                        res++;
                             out.println("<table width=600 align=center>");
                             str1 = disp(rs.getString(1),keywords[i]);
                             out.println(str1);
                             //if(str1.equals("null") || str1.equals(" ") || str1.equals(null))
                             if(str1 == "null" || str1 == "")
                                  str1 = "";
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Name </td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                                  //System.out.println(str1);
                                  //out.println(str1);
                             str2="";
                             str1 = disp(rs.getString(2),keywords[i]);
                             if(!str1.equals("") || !str1.equals(""))
                                  str2 = str1;          
                             str1 = disp(rs.getString(3),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             if(!str2.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Title, Affiliation</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>");
                                  out.println(str2);     
                                  out.println("</td></tr>");
                             str2="";
                             str1 = disp(rs.getString(4),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  str2 = str1;          
                             str1 = disp(rs.getString(5),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(6),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(7),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             str1 = disp(rs.getString(8),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  if(str2.length() > 0 || !str2.endsWith(", "))
                                       str2+= ", ";
                                  str2 += str1;
                             if(!str2.equals(""))
                                  out.println("<tr><td valign=top width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Address </td>");
                                  out.println("<td><font face=\"verdana, geneva, arial, sans-serif\" size=2>");
                                  out.println(str2);     
                                  out.println("</td></tr>");
                             str1 = disp(rs.getString(9),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Phone</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp(rs.getString(10),keywords[i]);
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Fax</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");      
                             str1 = disp(rs.getString(11),keywords[i]).toLowerCase();
                             if(!str1.equals(" ") || !str1.equals(""))
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>eMail</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp(rs.getString(12),keywords[i]).toLowerCase();
                             if(str1.equals("null") || str1.equals(" ") || str1.equals(null))
                                  str1="";
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Web Site</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             str1 = disp((rs.getString(13)).replace(',',' '),keywords[i]);
                             if(str1 == "null" || str1 == null || str1 == "")
                             //if(!rs.wasNull())
                                  out.println("nothing");
                             else
                                  out.println("<tr><td width=150><font color = green face=\"verdana, geneva, arial, sans-serif\" size=2><b>Key Words</td><td><font face=\"verdana, geneva, arial, sans-serif\" size=2>"+str1+"</td></tr>");
                             out.println("<tr><td width=150><hr></td><td><hr></td></tr>");
                             out.println("</table><br>");
                   } // end while
                   } // end if
                   catch(Exception e)
                        System.out.println("Exception while executing query: "+ e);
              } // end for
              if(!found)
                   out.println("<center><font color=#ff9999 face=\"verdana, geneva, arial, sans-serif\" size=2><b>Searched for \""+ key+"\", ");
                   out.println("Total Matches found : 0</center><br>");
              out.println("<center><a href=\"javascript:myclose()\"><font color=red face=\"verdana, geneva, arial, sans-serif\" size=2>Close</a></center>");
              out.println("</body></html>");
         public void doGet(HttpServletRequest req, HttpServletResponse res)
         throws IOException,ServletException
              doPost(req,res);
         public String disp(String str1, String str2)
              int i,j,k;
              boolean found=false;
              String s1,s2,s3;
              String t1,t2;
              t1 = initCap(str1);
              s1 = t1.toLowerCase();
              s2 = str2.toLowerCase();
              for(i=0;i<s1.length() && !found ;i++)
                   k=i;
                   for(j=0;j<s2.length() && k < s1.length() && s1.charAt(k) == s2.charAt(j) ;j++,k++);
                   if(j==s2.length())
                        found=true;
              if(found)
                   i--;
                   s3 = t1.substring(0,i);
                   s3 += "<font color=blue face=\"verdana, geneva, arial, sans-serif\" size=2><b>";
                   s3 += t1.substring(i,i+str2.length());
                   s3 += "</font></b>";
                   s3 += t1.substring(i+str2.length(),t1.length());
              else
                   s3 = t1;
              return s3;
         public String initCap(String str)
              StringTokenizer st = new StringTokenizer(str," ");
              String s1="";
              String s2="";
              String s3="";
              String s4="";
              while(st.hasMoreElements())
                   s1 = (String)st.nextElement();
                   if(s1.length() > 0)
                        s2 = s1.substring(0,1);
                        s2 = s2.toUpperCase();
                   if(s1.length() > 1)
                        s3 = s1.substring(1,s1.length());
                   s2 += s3;
                   s4 +=" "+s2;
              return s4;

  • Null values in Weblogic 7 HTTP Request Parameters

    It appears weblogic 7 handles nulls passed from the request object
              differently than the previous versions. In my jsp's, if a parameter
              was not passed, I used to get a java null value:
              String s = request.getParameter("something_not_passed");
              if(s == null) {
              //do stuff
              Now, weblogic seems to return the string literal "null" so I would
              have to use:
              if(s.equals("null")) {
              //do stuff
              Is this a bug or am I missing something?
              Thanks,
              Paul
              

    HI, Thanks for the reply. I am using getString() to fetch values.
    DO u think its due to driver incompatibility?? Because, BEA claims WL7.0 supports
    Oracle 8.1.7 onwards!
    Thanks,
    Yogesh
    Joseph Weinstein <[email protected]> wrote:
    >
    >
    Yogesh wrote:
    Hi, I have ported my web application from weblogic 5.1 to weblogic 7.Set up is weblogic
    7 with database Oracle 8.1.6 and i am using OCI driver for DB connectionpool. I
    am facing some problems like, the values that were retrieved as blanksin weblogic
    5.1 are being retrieved as null(string literal value) in 7. The same thinghappens
    when parameters were passed through HTTP request object. Any idea aboutthis?
    Thanks,
    YogeshHi. This sounds like a driver bug. Let's isolate it to a simple standalone
    program
    that uses our driver to select null data. How are you asking for the object?
    GetString(),
    GetObject()?
    Joe

  • Null values returned when using request.getParameters(

    I have a html form which allows the user to choose options and select a file to upload. When I use method=Post I get null values returned. When I use method=Get I get my parameter values fine.. but I get an error.
    "Posted content type isn't multipart/form-data"
    I would like to know why I am getting null values returned when using Post. I am using the following to get the values from the name=value passed to the servlet.
    String strIndustry = request.getParameter("frmIndustry");
              String strCompany = request.getParameter("frmCompany");
              String strCollabType = request.getParameter("frmCollaboration");
    I have another form where the user can search information in a database that works just fine w/ either Get or Post
    Or perhaps I am using oreilly MultipartRequest incorrectly??? but I copied it directly from another discussion.. ???
    any thoughts
    Thanks

    taybon:
    you could do it like this. in this case, you submit your form with the parameters (industry, company, collaboration), and upload your file at the same time. and in the target servlet, you can build your MultipartRequest object like this:
    MultipartRequest multi = new MultipartRequest(request, temp_location, 50 * 1024);where variable temp_location stands for a temporatory diretory for file uploading.
    and then you get your parameters, so you can build the directory with them. and after that, you can move your file to that directory using File.renameTo();
    but as i've suggested in my previous posting, i just recommend you upload your file in a separate form. and then you can perform an oridianry doPost form submit with those parameters. or you may have problems with the file uploading. (this is just my personal experiences with Multipart).
    there is one other thing i'd like to mention, file.renameTo() won't work if you need to move files to a network drive in windows. it won't work if you move files across file systems in unix.
    Song xiaofei
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Servlet only gets null values from mobile

    OK, i'm doing a project for college which involves inputting data into an application on a mobile device, sending them to a servlet and updating a database. I've got my mobile app working and sending but the servlet is only receiving null values for it. I'll post the code for d servlet and see if anyone can figure out whats wrong. The problem might not even be the servlet so i'll post part of the mobile app as well. The problem could well be when i'm buffering the content on the mobile to a string. Anyway, any help appreciated, thanks.
    The Servletimport java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.*;
    import java.util.logging.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class ThisServlet extends HttpServlet
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.println("<html>");
                out.println("<head>");
                out.println("<title>ThisServlet</title>"); 
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>Servlet at " + request.getContextPath () + "</h1>");
                out.println("</body>");
                out.println("</html>");
            } finally {
                out.close();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        @Override
        public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
            String connectionURL = "jdbc:mysql://localhost:3306/database";
            Connection connection = null;
            Statement stmt = null;
            ResultSet rs = null;
            res.setContentType("text/html");
            PrintWriter out = res.getWriter();
            String MobileNumber = req.getParameter("user");
            String field1 = req.getParameter("h1");
            String field2 = req.getParameter("h2");
            String field3 = req.getParameter("h3");
            try {
                // Load the database driver
                Class.forName("com.mysql.jdbc.Driver");
                // Get a Connection to the database
                connection = DriverManager.getConnection(connectionURL, "root", "root");
                try {
                    stmt = connection.createStatement();
                } catch (SQLException ex) {
                    Logger.getLogger(ThisServlet.class.getName()).log(Level.SEVERE, null, ex);
                rs = stmt.executeQuery("SELECT UserID FROM User WHERE MobileNumber = '" + MobileNumber + "'");
                while (rs.next()) {
                    String UserID = rs.getString("UserID");
                    String insert = "INSERT INTO newTable(UserID, One, Two, Three) VALUES (?,?,?,?)";
                    PreparedStatement pst = connection.prepareStatement(insert);
                    pst.setString(1, UserID);
                    pst.setString(2, field1);
                    pst.setString(3, field2);
                    pst.setString(4, field3);
                    pst.executeUpdate();
                    pst.close();
            catch(ClassNotFoundException e){
                System.out.println(e.toString());
            catch(SQLException e){
                System.out.println(e.toString());
            catch (Exception e){
                System.out.println(e.toString());
            finally {
                // Always close the database connection.
                try {
                    if (connection != null) connection.close();
                    System.out.print("closing db connection ... \n");
                catch (SQLException ignored){
                    out.println(ignored);
        @Override
        public String getServletInfo() {
            return "Short description";
    }The Mobile App (only part where putting the content together to send)
    buffer.append("user="+mobileNumber).append("?h1="+field1)
                        .append("?h2="+field2).append("?h3="+field3);
                content = buffer.toString();
    sendToServer(url, content);

    For sure you would have to do following on your mobile:
    buffer.append("?user="+mobileNumber).append("&h1="+field1)
                        .append("&h2="+field2).append("&h3="+field3);
                content = buffer.toString();
    sendToServer(url, content);'?' - is a delimiter of GET parameters and '&' - is a delimiter between GET parameters
    Edited by: ivanovpv on 30.04.2009 10:57

  • Problem in sending drop down list value to jsp page showing  null value

    i am trying to send a drop down list value from client side to a jsp page but getting null value
    this is first page where i have accessed data from database and putted it in a drop down list
    <select name="sub">
         <%
         while(rs2.next())
         cat=rs2.getString(1);
         %><option value="<%=cat%>"><%=cat%></option><%
         }%></select>
    <input type="submit" value="Go"></input>
    now on submit i am going to another page
    where i want the selected value from drop down list to be printed
    i have used there
    <%
    String subject= request.getParameter( "sub.value" );
    out.println(subject);
    %>
    but it is printing null here what is the problem that i m facing
    thanx & reagrds
    sweety

    how to generate dynamically names for text boxes
    i am generating text boxes in while loop when selecting data from database
    while(rs1.next())
    name=rs1.getString(1);%>
    <tr>
    <td>1</td>
    <td><%out.println(name);
    //i am printing here stud_id a unique key and want to update records from following text boxes to particular stud_id
    %></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    <td><input type="text" name="????"></input></td>
    </tr><%
    the structure is like
    stud_id | attended theory | conducted theory | ateended practical | conducted practical
    where attended theory, conducted theory............. are to be inputed manually for all students and then update in database
    so i am facing problem in generating names for textboxes how to do that
    so that those can be updated in database for particular student
    Thanx & Regards
    sweety

  • Binding for "File Content Repository Path" is returning null value

    I have created a data control for file based content repository based on an existing file system path. *But when this data contol is invoked the command "#{bindings['getURI_returnURI'].inputValue}" is returning null.*+
    Please advice what are possible scenarios. I have performed the following
    #1. Create a file system folder in windows XP named "C:\CPContentRepository" and add some html pages into this folder.
    #2. Create a "content" project in the application.
    #3. Create a "Content Repository Data Control" named "CPFileContentRepository". Repository Type : "File System", Base Path : "C:\CPContentRepository". Test & Registration is successful.
    #4. Add a "panel horizontal" into jsf jsp "ContentTest" page & drap-dop data control "CPFileContentRepository--> getURI(String)--> Return--> URI". select return type as "ADF Output Text".
    #5. Edit Authorization of the "ContentTest" page definition for "View --> anyone".
    #6. Edit Authorization of the "ContentTest" page definition bindings "getURI" for "Invoke --> anyone".
    #7. Run the "ContentTest" page. The output for the page is empty.
    Regards,
    Vikki

    There're two major problems in your code. One you have used different names to get your parameters like in your first jsp they're like
    <input type="text" name="did" size="20" </p>
      <p align="center"> </p>
      <p align="center"><b>Name        </b>          
      <input type="text" name="name" size="20"></p>
      <p align="center"> </p>
      <p align="center"><b>Specialist In         
      <input type="text" name="specialist" size="20"></b></p>
      <p align="center"> </p>
      <p align="center"><b>Address                
      <input type="text" name="address" size="20"></b></p>
      <p align="center"> </p>
      <p align="center"><b>Phone no.            
      <input type="text" name="phno" size="20"></b></p>
      <p align="center"> </p>but when you're getting you're doing it like this
    String name = request.getParameter("name");
         String did = request.getString("did");
         String add = request.getParameter("add");
         String specilist = request.getParameter("specilist");
         String phno = request.getParameter("phno");First get them with same name as you have them in your first jsp. another thing in that you're not used form tag in write way... You have created submit button in some other form
    and when you're pressing submit button actully you're submitting only that form value and your form1 is not submitted that's why you're getting null values for
    those parameters you're getting with right name

  • Problem when passing string array in sessions showing null value

    i am trying to pass a string array but it is showing me the null value
    i think the the problem is seem to be in session.settAttribute("subject['"+i+"']",subject) in 2.login_action.jsp
    or in String sub1=(String) session.getAttribute("subject[0]"); in 3.user_home.jsp
    i have following three pages
    1.login.html
    2.login_action.jsp
    3.user_home.html
    1.login.html
    <html>
    <body>
    <form method="post" action="login_action.jsp">
    Username<input type="text" name="username"></input>
    <br>
    Password<input type="password" name="password"></input>
    <input type="submit" value="login"></input>
    </form>
    </body>
    </html>
    2.login_action.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <%!
    String user,pwd;
    String subject[]=new String[10];
    int i,totalsubject;
    %>
    <%
    try
    user=request.getParameter("username");
    pwd=request.getParameter("password");
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:ods","scott","tiger");
    PreparedStatement ps = con.prepareStatement("select password from users where username='"+user+"'");
    ResultSet rs = ps.executeQuery();
    if(rs.next())
    if(rs.getString("password").equals(pwd))
    session.setAttribute("username",user);
    PreparedStatement ps2 = con.prepareStatement("select subject_id from allot_teachers where staff_id='"+user+"'");
                        ResultSet rs2 = ps2.executeQuery();          
                             while(rs2.next())
                             i=0;
                             subject[i]=rs2.getString(1);
    // if i display here the subjects in out.println(subject[i]) it is working fine
    // but in next redirected page it is showing null
                             session.setAttribute("subject['"+i+"']",subject[i]);
                             //out.println(subject[i]);
                             i++;
    response.sendRedirect("user_home.jsp");
    else
    out.println("error invalid username or password");
    else
    out.println("error invalid username or password");
    con.close();
    catch(Exception e)
    out.println(e);
    %>
    3. user_home.jsp
    <%@ page contentType="text/html"%>
    <%@ page import="java.sql.*" %>
    <html>
    <%
    String user,pwd,cat,cat1;
    String username=(String) session.getAttribute("username");
    if(username==null)
    response.sendRedirect("login.html");
    //just tried for first two subjects
    String sub1=(String) session.getAttribute("subject[0]");
    String sub2=(String) session.getAttribute("subject[1]");
    //here it is printing null
    out.println(sub1);
    //here it is printing null
    out.println(sub2);
    %>
    <form method="post" action="logout.jsp">
    <input type="submit" value="Logout"></input>
    </form>
    </html>
    Cheers & Regards
    sweety

    The name in getAttributre doesnt match the name in setAttribute.
    Note "subject[0]" is a string containing 10 chars, "subject" is a string containing 7 chars.
    Here is your code:
    session.setAttribute("subject",subject);
    String sub1=(String) session.getAttribute("subject[0]");

  • JDBC MS Access--- cannot extract entry with null value with data type Meta

    I'm trying to extract a data entry with null value by using JDBC. The database is MS Access.
    The question is how to extract null entry with data type memo? The following code works when the label has data type Text, but it throws sqlException when the data type is memo.
    Any advice will be appreciated! thanks!
    Following are the table description and JDBC code:
    test table has the following attributes:
    Field name Data Type
    name Text
    label Memo
    table contents:
    name label
    me null
    you gates
    Code:
    String query = "SELECT name, label FROM test where name like 'me' ";
    ResultSet rs = stmt.executeQuery(query);
    while (rs.next())
    String name = rs.getString("name");
    rs.getString("val");
    String label = rs.getString("label");
    System.out.println("\t"+name+"\t"+label);
    catch (SQLException ex)
    System.out.println(ex.getSQLState());
    System.out.println(ex.getErrorCode());
    System.out.println("in sqlexception");
    output:
    C:\Temp\SEFormExtractor>java DBTest
    yet SELECT name, label FROM test
    null
    0
    in sqlexception

    The question is how to extract null entry with data type memo?Okay, what you need to do is this:
    if (rs.getString("val") == null)
      // do something
    }This way, when it's a null value, you can check it first, and then handle it how you want, rather than getting an exception.

  • Index (or not) for excluding NULL values in a query

    Hello,
    I have table that can become very large. The table has a varchar2 column (let's call it TEXT) that can contain NULL values. I want to process only the records that have a value (NOT NULL). Also, the table is continuously expanded with newly inserted records. The inserts should suffer as little performance loss as possible.
    My question: should I use an index on the column and if so, what kind of index?
    I have done a little test with a function based index (inspired by this Tom Kyte article: http://tkyte.blogspot.com/2006/01/something-about-nothing.html):
    create index text_isnull_idx on my_table(text,0);
    I notice that if I use the clause WHERE TEXT IS NULL, the index is used. But if I use a clause WHERE TEXT IS NOT NULL (which is the clause I want to use), a full table scan is performed. Is this bad? Can I somehow improve the speed of this selection?
    Thanks in advance,
    Frans

    I build a test case with very simple table with 2 columns and it shows that FTS is better than index access even when above ratio is <= 0.01 (1%):
    DROP TABLE T1;
    CREATE TABLE T1
               C1 VARCHAR2(100)
              ,C2 NUMBER
    INSERT INTO T1 (SELECT TO_CHAR(OBJECT_ID), ROWNUM FROM USER_OBJECTS);
    BEGIN
         FOR I IN 1..100 LOOP
              INSERT INTO T1 (SELECT NULL, ROWNUM FROM USER_OBJECTS);
         END LOOP;
    END;
    CREATE INDEX T1_IDX ON T1(C1);
    ANALYZE TABLE T1 COMPUTE STATISTICS
         FOR TABLE
         FOR ALL INDEXES
         FOR ALL INDEXED COLUMNS
    SET AUTOTRACE TRACEONLY
    SELECT
              C1, C2
         FROM T1 WHERE C1 IS NOT NULL;
    3864 rows selected.
    real: 1344
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=59 Card=3864 Bytes=30912)
       1    0   TABLE ACCESS (FULL) OF 'T1' (Cost=59 Card=3864 Bytes=30912)
    Statistics
              0  recursive calls
              0  db block gets
           2527 consistent gets
           3864 rows processed
    BUT
    SELECT
         --+ FIRST_ROWS
              C1, C2
         FROM T1 WHERE C1 IS NOT NULL;
    3864 rows selected.
    real: 1296
    Execution Plan
       0      SELECT STATEMENT Optimizer=HINT: FIRST_ROWS (Cost=35 Card=3864 Bytes=30912)
       1    0   TABLE ACCESS (BY INDEX ROWID) OF 'T1' (Cost=35 Card=3864 Bytes=30912)
       2    1     INDEX (FULL SCAN) OF 'T1_IDX' (NON-UNIQUE) (Cost=11 Card=3864)
    Statistics
              0  recursive calls
              0  db block gets
           5052 consistent gets
           3864 rows processed
    and just for comparison:
    SELECT * FROM T1 WHERE C1 IS NULL;
    386501 rows selected.
    real: 117878
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=59 Card=386501 Bytes=3092008)
       1    0   TABLE ACCESS (FULL) OF 'T1' (Cost=59 Card=386501 Bytes=3092008)
    Statistics
              0  recursive calls
              0  db block gets
         193850 consistent gets
         386501 rows processedHence you have to benchmark you queries with and w/o index[es]

  • How to validate if a column have NULL value, dont show a row with MDX

    Hello,
    I have this situation, I have a Result from MDX that return rows with values NULL on columns, I tried with NON EMPTY and NONEMPTY but the result is the same. That I want to do is validate if a column have a Null value discard the row, but I dont know how
    to implement it, could somebody help me?, please.
    Thanks a lot.
    Sukey Nakasima
    Sukey Nakasima

    Hello,
    I found the answer in this link https://social.technet.microsoft.com/Forums/sqlserver/en-US/f9c02ce3-96b2-4cd6-921f-3679eb22d790/dont-want-to-cross-join-with-null-values-in-mdx?forum=sqlanalysisservices
    Thanks a lot.
    Sukey Nakasima
    Sukey Nakasima

Maybe you are looking for

  • SCVMM Cloud Capacity Limitations don't match what OS reports

    So, in SCVMM we're going to be using clouds to limit how much resources different business groups can consume. I've created a number of clouds, and when VMs are created within them, each cloud reports a "Utilization" in the overview pane, basically s

  • Video Controller Failure.

    After a couple of months of kernel panics, freezing, etc., a Hardware Test finally produced the sad conclusion that the NVIDIA 8600M GT video controller in my MBP had failed. This is the well documented fault that has been occurring since 2007/2008.

  • Pings in evening

    Hi, I'm having problems with pings in the evening on bt total broadband option 3. Speed is mostly fine but pings after 6pm go from 30ms to around 100-300 when checked with tracert. It only started last week and nothing has changed on my end. It makes

  • After installation of Mac OS 10.10.3, my MacBook Pro can't boot anymore.

    I have MacBook Pro late 2013 with Mavericks 10.10.2.  This morning after installation update, my MBP rebooted itself and can't find the installed OS. MBP late 2013, 2,6 GHz i5 processor with 512 gb flash, OS X 10.10.2. System disk had two partitions.

  • I forget my unlock volume limit password. What do i do?

    I forget my volume limit password. What do i do? i have tryed all my passwords that i think it could be and it doesent even tell me if im wrong or not. HELLLLLLLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!