Click to See Complete Forum and Search --> : not sure why the servlet wont run


everytime
June 18th, 2005, 10:47 AM
hi there , i have created these 2 pages and tried running them , not sure why it does not run .. the server is using tomcat and database is using postgres

i am sure that the sql statements works fine just the after clicking the link to the jsp page , it does not call the servlet ... thus nothing will be displayed .. not sure where is wrong also .. i tried editing the web.xml mapping but to no avail ..

another thing is that the fileoutput does not output any xml file ... user home is under documents and setting ( computer profile name )

below is the servlet ...

package org.poc.rwb.role.servlet;

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;

import javax.servlet.*;
import javax.servlet.http.*;

import org.freebxml.omar.server.util.*;
import org.poc.awb.role.*;
import org.poc.uwb.createFile.CreateBean;
import org.poc.uwb.readFile.FileBean;


public class QueryRequestRoleServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
ArrayList myValue = new ArrayList();
ArrayList myUUID = new ArrayList();
String a;
String b;
String c;
String d;
String e;
String f;
String g;
String h;
String sql = null;

String user_home = System.getProperty("user.home");

a = ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!-- $Header$ -->\n" +
"<AdhocQueryRequest xmlns=\"urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0\" " +
"xmlns:lcm=\"urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0\" " +
"xmlns:query=\"urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0\" " +
"xmlns:rim=\"urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0\" " +
"xmlns:rs=\"urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
"xsi:schemaLocation=\"urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0 ../../../ebxmlrr-spec/misc/3.0/schema/query.xsd\">\n\n\t" +
"");
b = ("<query:ResponseOption returnComposedObjects=\"true\" returnType=\"LeafClass\"/>\n\t\t");
c = ("<rim:AdhocQuery id=\"tempId\">\n\t");
d = (" <rim:QueryExpression queryLanguage=\"urn:oasis:names:tc:ebxml-regrep:QueryLanguage:SQL-92\">\n\t");

sql = ("SELECT code FROM ClassificationNode where parent = 'urn:oasis:names:tc:ebxml-regrep:classificationScheme:SubjectRole'\n");

e = ("</rim:QueryExpression>\n\t");

f = ("</rim:AdhocQuery>\n");

g = ("</AdhocQueryRequest>");

try
{

FileOutputStream fos = new FileOutputStream(user_home+"/regseg/test/AWB/Request/QueryRequestRole.xml");
Writer out = new OutputStreamWriter(fos, "UTF8");

out.write(a + b + c + d + sql + e + f + g);
out.close();

}

catch (IOException ex) {
ex.printStackTrace();
}
System.out.println("retrieving");


String [] args;
args = new String [9];
args [0]= ("req="+user_home+"\\regseg\\test\\UWB\\Request\\QueryRequestRole.xml");
args [1]= ("keyStoreType=jks");
args [2]= ("keyStorePassword=ebxmlrr");
args [3]= ("keyPassword=urn:freebxml:registry:predefinedusers:registryoperator");
args [4]= ("alias=urn:freebxml:registry:predefinedusers:registryoperator");
args [5]= ("url=http://localhost:8080/omar/registry/soap");
args [6]= ("localCall=false");
args [7]= ("res="+user_home+"\\regseg\\test\\UWB\\Response\\QueryResponseRole.xml");
args [8]= ("keyStore="+user_home+"\\omar\\3.0-post-alpha2-dev\\jaxr-ebxml\\security\\keystore.jks");
System.out.println("sender");

SOAPSender.mySOAPSender(args);

FileReader fr = new FileReader(user_home+"/regseg/test/UWB/Response/QueryResponseRole.xml");
BufferedReader in = new BufferedReader(fr);

String str;

while ((str = in.readLine())!= null) {

if (str.startsWith(" <ns1:LocalizedString")){
String[] line = str.split(" <ns1:LocalizedString charset=\"UTF-8\" value=\"");
for (int i=0; i<line.length; i++){

String[] value = line[i].split("\" ");

for (int j=0; j<value.length; j++){

String test = value[j];

myValue.add(test);
}
}
}
else if (str.startsWith(" <ns1:ExtrinsicObject isOpaque")){
String[] line = str.split("id=\"");
for (int i=0; i<line.length; i++){

String[] value = line[i].split("\" ");


for (int j=0; j<value.length; j++){
System.out.println("value["+j+"]" + value[j]);
String test = value[j];
myUUID.add(test);
}

}

}
}
FileBean file = new FileBean();

file.setMyValue(myValue);
file.setMyUUID(myUUID);

HttpSession session = request.getSession(true);
session.setAttribute("file",file);


response.setContentType("text/html");
request.getRequestDispatcher("awb_view_role.jsp").forward(request, response);

}

}


here is the jsp page

<html>

<head>
<title>Welcome To Administrator Workbench - View Role</title>
<link href="reg_styles.css" rel="stylesheet" type="text/css">
<jsp:useBean id="file" class="org.poc.uwb.readFile.FileBean" scope="session"/>
<jsp:useBean id="LB" class="org.poc.uwb.login.loginBean" scope="session"/>
<%@page import="java.util.*"%>
<head>

<body>
<table align="center" width="100%" border="1" frame="box" cellpadding="0" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111" height="98">
<tr>
<td colspan="2" background="images/topa.jpg" width="40%" height="19">&nbsp;
</td>
</tr>
<tr valign="center">
<td colspan="2" align="left" width="94%" height="44">
<p align="right">
<img border="0" src="images/Net.png" width="300" height="54" align="left">
<img border="0" src="images/workbench.jpg" width="394" height="54" align="right">
</td>

</tr>
<tr>
<td class="forTexts" background="images/basicmenubg.jpg" bgcolor="#E4E6E7" height="19" width="94%">
&nbsp;</td>
</tr>
</table>

<!--MAIN TABLE-->
<table align="center" width="100%" border="1" frame="box" cellpadding="0" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111">
<!--CENTER-->
<tr height="380">
<td valign="top">
<table border="0" width="100%" cellpadding="10" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<!--CENTER LEFT-->
<td valign="top" width="129">
<table border="0" cellpadding="3" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111" width="136">
<!--Menu-->

<jsp:include page="awb_menu.jsp"/>
<tr>
<td>

</td>
</tr>
</table>
</td>
<!--END_CENTER_LEFT-->

<!--CENTER RIGHT-->
<td valign="top" width="850">
<table border="0" cellpadding="3" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111" width="759">
<tr>
<td valign="top" width="753">
<!------------------FORM FOR USER ROLE------------------>
<table border="0" cellpadding="5" cellspacing="0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#111111" width="94%" height="110">
<tr>
<td colspan="2" bgcolor="#e4e6e7" class="forHeader" width="679" height="1">
<b>View Role</b></td>
</tr>

<tr>
<td width="237">
<table border="1" width="237">
<tr>
<th>Name</th>
<!--<th>Description</th>-->
</tr>

<%
ArrayList value = file.getMyValue();
for ( int i = 1; i < value.size(); i++ )
{

%>
<tr>
<td bgcolor="#f3f4f5" height="60">
<%=(String)(value.get(i))%> &nbsp;</td>

<%
i++;
i++;

%>

<%
i++;
i++;
i++;

}
%>
</tr>
</table>
</td>

<!--

</td>
</tr>
</table>
</body>

</html>

everytime
June 20th, 2005, 04:48 AM
hahah i solved my problems , but may i know is there a way for say like a jsp page to use 2 servlets of have 2 sql statements ? can point me in the direction to it

thanks