Problem calling out servlet
I have written an application using Visual Cafe. I tried to called out the application thru my server but i got this error below. Anyone has any idea whats wrong?
java.lang.NullPointerException
at java.lang.ClassLoader.resolveClass0(Native Method)
at java.lang.ClassLoader.resolveClass(ClassLoader.java:573)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java, Compiled Code)
at org.apache.tomcat.loader.AdaptiveServletLoader.loadClass(AdaptiveServletLoader.java:174)
at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:265)
at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:289)
at org.apache.tomcat.core.Handler.service(Handler.java, Compiled Code)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java, Compiled Code)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java, Compiled Code)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
at java.lang.Thread.run(Thread.java:479)
Desperate.......
Below is the source code generated by Visual Cafe.I am using ver 4.
A basic extension of the java.awt.Frame class
import java.awt.*;
import com.symantec.itools.javax.swing.actions.JActionButton;
import symantec.itools.awt.util.ToolBarPanel;
import symantec.itools.awt.ImageHTMLLink;
import symantec.itools.awt.util.ToolBarSpacer;
import javax.swing.JToolBar;
import com.symantec.itools.javax.swing.JToolBarSeparator;
import symantec.itools.awt.ImageButton;
import symantec.itools.awt.BorderPanel;
import symantec.itools.awt.KeyPressManagerPanel;
import com.symantec.itools.javax.swing.JButtonGroupPanel;
import symantec.itools.awt.StatusBar;
import javax.swing.*;
public class Prototype extends Frame
public Prototype()
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setBackground(new java.awt.Color(215,215,215));
setSize(600,449);
setVisible(false);
add(canvas1);
canvas1.setBackground(java.awt.Color.white);
canvas1.setBounds(96,0,408,449);
try {
toolBarPanel1.setIPadSides(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel1.setIPadTop(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel1.setOrientation(symantec.itools.awt.util.ToolBarPanel.VERTICAL);
catch(java.beans.PropertyVetoException e) { }
add(toolBarPanel1);
toolBarPanel1.setBounds(504,0,96,449);
try {
imageHTMLLink1.setLinkURL(symantec.itools.net.RelativeURL.getURL("www.google.com"));
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
try {
imageHTMLLink1.setImageURL(new java.net.URL("file:///D:/FYP/google2.GIF"));
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
toolBarPanel1.add(imageHTMLLink1);
try {
toolBarSpacer1.setSpace(20);
catch(java.beans.PropertyVetoException e) { }
toolBarPanel1.add(toolBarSpacer1);
try {
imageHTMLLink2.setImageURL(new java.net.URL("file:///D:/FYP/yahoo3.JPG"));
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
toolBarPanel1.add(imageHTMLLink2);
try {
toolBarPanel3.setIPadBottom(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel3.setIPadSides(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel3.setIPadTop(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel3.setOrientation(symantec.itools.awt.util.ToolBarPanel.VERTICAL);
catch(java.beans.PropertyVetoException e) { }
add(toolBarPanel3);
toolBarPanel3.setBounds(0,192,96,48);
button1.setLabel("Y");
toolBarPanel3.add(button1);
button1.setBackground(java.awt.Color.lightGray);
button1.setFont(new Font("Dialog", Font.PLAIN, 15));
button3.setLabel("N");
toolBarPanel3.add(button3);
button3.setBackground(java.awt.Color.lightGray);
button3.setFont(new Font("Dialog", Font.PLAIN, 15));
try {
toolBarPanel4.setIPadSides(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel4.setIPadTop(10);
catch(java.beans.PropertyVetoException e) { }
try {
toolBarPanel4.setOrientation(symantec.itools.awt.util.ToolBarPanel.VERTICAL);
catch(java.beans.PropertyVetoException e) { }
add(toolBarPanel4);
toolBarPanel4.setBounds(0,0,96,192);
try {
imageButton1.setImageURL(new java.net.URL("file:///D:/FYP/questions.JPG"));
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
toolBarPanel4.add(imageButton1);
try {
toolBarSpacer2.setSpace(20);
catch(java.beans.PropertyVetoException e) { }
toolBarPanel4.add(toolBarSpacer2);
try {
imageButton2.setImageURL(new java.net.URL("file:///D:/FYP/pen.JPG"));
catch (java.net.MalformedURLException error) { }
catch(java.beans.PropertyVetoException e) { }
toolBarPanel4.add(imageButton2);
try {
toolBarPanel5.setOrientation(symantec.itools.awt.util.ToolBarPanel.VERTICAL);
catch(java.beans.PropertyVetoException e) { }
add(toolBarPanel5);
toolBarPanel5.setBounds(0,240,96,209);
setTitle("A Simple Frame");
//{{INIT_MENUS
menu1.setLabel("Main");
menu1.add(menuItem1);
menuItem1.setLabel("MenuItem");
menuBar1.add(menu1);
menu2.setLabel("Tools");
menu3.setLabel("Applications");
menu3.add(menuItem2);
menuItem2.setLabel("Powerpoint");
menu3.add(menuItem3);
menuItem3.setLabel("Words");
menu2.add(menu3);
menuBar1.add(menu2);
menu4.setLabel("Help");
menuBar1.add(menu4);
//$$ menuBar1.move(0,423);
setMenuBar(menuBar1);
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
public Prototype(String title)
this();
setTitle(title);
* Shows or hides the component depending on the boolean flag b.
* @param b if true, show the component; otherwise, hide the component.
* @see java.awt.Component#isVisible
public void setVisible(boolean b)
if(b)
setLocation(50, 50);
super.setVisible(b);
static public void main(String args[])
(new Prototype()).setVisible(true);
public void addNotify()
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
Insets insets = getInsets();
setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
Point p = components.getLocation();
p.translate(insets.left, insets.top);
components[i].setLocation(p);
fComponentsAdjusted = true;
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.Canvas canvas1 = new java.awt.Canvas();
symantec.itools.awt.util.ToolBarPanel toolBarPanel1 = new symantec.itools.awt.util.ToolBarPanel();
symantec.itools.awt.ImageHTMLLink imageHTMLLink1 = new symantec.itools.awt.ImageHTMLLink();
symantec.itools.awt.util.ToolBarSpacer toolBarSpacer1 = new symantec.itools.awt.util.ToolBarSpacer();
symantec.itools.awt.ImageHTMLLink imageHTMLLink2 = new symantec.itools.awt.ImageHTMLLink();
symantec.itools.awt.util.ToolBarPanel toolBarPanel3 = new symantec.itools.awt.util.ToolBarPanel();
java.awt.Button button1 = new java.awt.Button();
java.awt.Button button3 = new java.awt.Button();
symantec.itools.awt.util.ToolBarPanel toolBarPanel4 = new symantec.itools.awt.util.ToolBarPanel();
symantec.itools.awt.ImageButton imageButton1 = new symantec.itools.awt.ImageButton();
symantec.itools.awt.util.ToolBarSpacer toolBarSpacer2 = new symantec.itools.awt.util.ToolBarSpacer();
symantec.itools.awt.ImageButton imageButton2 = new symantec.itools.awt.ImageButton();
symantec.itools.awt.util.ToolBarPanel toolBarPanel5 = new symantec.itools.awt.util.ToolBarPanel();
//{{DECLARE_MENUS
java.awt.MenuBar menuBar1 = new java.awt.MenuBar();
java.awt.Menu menu1 = new java.awt.Menu();
java.awt.MenuItem menuItem1 = new java.awt.MenuItem();
java.awt.Menu menu2 = new java.awt.Menu();
java.awt.Menu menu3 = new java.awt.Menu();
java.awt.MenuItem menuItem2 = new java.awt.MenuItem();
java.awt.MenuItem menuItem3 = new java.awt.MenuItem();
java.awt.Menu menu4 = new java.awt.Menu();
class SymWindow extends java.awt.event.WindowAdapter
public void windowClosing(java.awt.event.WindowEvent event)
Object object = event.getSource();
if (object == Prototype.this)
Prototype_WindowClosing(event);
void Prototype_WindowClosing(java.awt.event.WindowEvent event)
setVisible(false); // hide the Frame
Similar Messages
-
Problems calling Java Servlets from HTML pages Online
Hello
I have created a Web site using Java Servlets, and have acquired some servlet enabled web-space however i am having some difficulty in calling the actual servlets from the HTML pages i was using the line of code as follows
http://localhost:8080/servlet/....
followed by the name eg.
http://localhost:8080/servlet/Login
however this doesn't seem to be working i have also tried using the exact address of the servlet but this didn't work either
i.e ..servlet/Login.java
I was wondering would anyone have any idea as in how the servlets should be called
Thanks very muchOnce you write the Servlet code, you have to compile and put the classes in the server classpath. To refer these servlets from your pages, you have to configure them in the server configuration(typical a xml file). There you define how you are going to refer to the servlet(/servlet/Logon) and the correponding class.
-Mak -
Problem calling servlet from JSP
Hi All,
I am running Tomcat 4.1.31 + Apache 2.0.54 for a web app. I have a jsp in a folder in my context root that is calling a servlet. My web.xml looks like this
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <web-app>
<display-name>Web Application</display-name>
- <!-- +===========================================+
| SERVLET: Controller |
+===========================================+
-->
- <servlet>
<servlet-name>Controller</servlet-name>
<description>Testing Servlets</description>
<servlet-class>servlets.Controller</servlet-class>
<load-on-startup />
</servlet>
- <servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/Controller</url-pattern>
</servlet-mapping>
</web-app>
and my jsp is as below:
<form name="loginForm" id="loginForm" action="/Controller" method="post">
<table border="1" cellpadding="5" width="300">
<tr>
<td>User Id </td>
<td><input type="text" name="userid" size="20" maxlength="15"/></td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="passwd" size="20" maxlength="10"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="submit" id="submit" value="Submit"/>
</td>
</tr>
</table>
<input type="hidden" name="action" id="action" value="login"/>
</form>
However, this doesnt work at all. Whenever I hit the submit button I get a 404 File not Found error.
I have to give the entire url starting with the context root in the JSP for the servlet to work. Is that how it is supposed to work?? I was under the impression that once everything is defined correctly, Tomcat will figure out that the JSP and the servlet belong to the same app and get it from there.
Can anyone help me please???
Let me know if anything is not clear enough.
Thank you!
amrutaaActually this is just an example app ... but I am going to have other jsps that will call the controller servlet ..
Thanks a lot for your help. I really appreciate it.
What stumps me is that the call to the servlet was working day before yesterday and yesterday it just wouldnt!
and I am sure I touched only the servlet in the meanwhile + restarted Apache as well as Tomcat.
Thanks again!
-Amruta -
Problems with UTL_DBWS calling out a web service.
I´m using ORACLE 10G 10.2.0 and i ´ve downloaded the dbws-callout-utility-10R2.zip utility l´ve unziped it and launched it .
the command loadjava -u SCOTT/passwd -r -v -f -genmissing dbwsclientws.jar dbwsclientdb102.jar ended without errors.
then I gave grant access using the following commands
the environment variable is
$TMPCLASSPATH=$ORACLE_HOME/sqlj/lib/dbwsa.jar:$ORACLE_HOME/jdk/lib/dt.jar:$ORACLE_HOME/jdk/lib/tools.jar:$ORACLE_HOME/sqlj/lib/runtime12.jar:$ORACLE_HOME/sqlj/lib/translator.jar:$ORACLE_HOME/javavm/lib/aurora.zip:$ORACLE_HOME/rdbms/jlib/xdb.jar:$ORACLE_HOME/lib/xsu12.jar:$ORACLE_HOME/jlib/jndi.jar:$ORACLE_HOME/rdbms/jlib/aqapi.jar:$ORACLE_HOME/rdbms/jlib/jmscommon.jar:$ORACLE_HOME/lib/xmlparserv2.jar:$ORACLE_HOME/jlib/orai18n.jar:$ORACLE_HOME/jdbc/lib/ojdbc14.jar
call dbms_java.grant_permission( 'SCOTT','SYS:java.lang.RuntimePermission', 'shutdownHooks', '' );
COMMIT;
call dbms_java.grant_permission( 'SCOTT', 'SYS:java.util.logging.LoggingPermission', 'control', '' );
COMMIT;
call dbms_java.grant_permission( 'SCOTT', 'SYS:java.lang.RuntimePermission', 'setFactory', '' );
COMMIT;
then I created the package running UTL_DBWS .SQL scripts
when I run a test for calling out the web service I got the next error.
ORA-29532: UNCAUGHT JAVA EXCEPTION : Java.Lang.IllegalAccessException: java.lang.ExceptionLnLn
at line
" function create_service_proxy(wsdl_Document_Location VARCHAR2, service_Name VARCHAR2) return SERVICE
as language java 'oracle.jpub.runtime.dbws.DbwsProxy.createService(java.lang.String,java.lang.String) return long' "
name 'oracle.jpub.runtime.dbws.DbwsProxy.createService(java.lang.String,java.lang.String) return long';
Is necessary to install the jpublisher in addition for a sucessfully web service calling out?
what goes wrong?
Thanks for the soon answer.I have exactly the same problem.
All possible grants are made.
Running as SYS is not functioning as well.
The same installation (the same jar's, the same utl_dbws version, the same database version) does function on two other (developers team's) servers .
The differences are:
Where it functions: Oracle database Enterprise edition on Windows (Windows 7, Vista)
Where it does not function: Oracle database Stadard edition on Unix
I have gone though a decent number of forums and other on-line resources with no success. Solutions available are to grant missing permissions. However these solutions are based on the assumption that under SYS user everything functions properly.
In my case, this does not function even under SYS as SYSDBA.
I will highly appreciate any recommendations!
Best Regards,
Michail
P.S.
Database: Oracle 10.2.0.1 Standard edition installed on Unix -
Problem in calling jsp/servlets ...Last Day
when ever I call jsp page from browser, It always search the jsp page in the parent directory of the documentroot directory.
Also I am not able to set the configuration for calling the servlet from my customize laocation. is any other entry needed except specifying the repositry path in zone.properties file.
Please help...........I have not very time left for evaluation of 9ias 1.0.2.0.0
If any one encountered this type of problem. pls respond immediately
I have installed 9ias v10200 enterprise edition with oracle 8.1.6(enterprise edition) as origin database on winnt server 4.0 with service pack 5. At the time of installation I have selected oracle web cache , forms & reports to be configured at the time of installation.
I am using port say 10000 other than default port 80, but on same IP.
I have entered the folling entries at the end of httpd.conf file.
<VirtualHost 192.168.1.120:10000>
ServerName rnd1
DocumentRoot e:/test
DirectoryIndex hi.html
</VirtualHost>
Listen 80
Listen 10000
now when I request "http://rnd1:10000/ClamHome.jsp" from browser, It gives the messege that source file "ClamHome.jsp" not found on path "e:\" which is the parent of my documentroot path. Why it try to search at parent directory of document root????????
another thing is that, when I run the demos of jsp given with 9ias v10200, they works(jsps) fine.
but after running the demo which is on port 80 with documentroot e:\9\Apache\Apache\htdocs,
I again call my ClamHome.jsp at rnd1:10000 then it gives error that file not found at "e:\9\Apache\Apache\htdocs". Strange behaviour, this time it searches on path which I called earlier.
pls help
nullI would try to change "./Welcome.jsp" to "/Welcome.jsp". I'm not sure what that period will do.
Are you able to access that JSP directly from your browser (even if it's not designed to be accessed that way)? If not, then you have some other problem.
When you say you get a 404 when you access the servlet, is that when you access the servlet, or when it tries to forward to the JSP? If you get the 404 when you access the servlet, perhaps your servlet-mapping to the servlet is invalid. -
HT1414 i restored my iphone now i cant accept calls or call out whats the problem?
i restored my iphone now i cant accept calls or call out whats the problem?
Hey retrothakid,
Thanks for the question. I understand that you are experiencing issues with your iPhone 4s. The following resource may provide a solution:
iPhone: Troubleshooting issues making or receiving calls
http://support.apple.com/kb/TS3406
Thanks,
Matt M. -
Busy signal when trying to call out while vacationing in Puerto Rico. How can I fix this problem?
Lmercer81,
Thanks for the update! Let's continue to take a closer look. What model phone do you have? Do you have any bars of signal on the device? Has this effected data or text? Are you able to receive incoming calls?
EfrainM_VZW
Follow us on Twitter @VZWSupport -
Problem in Download Servlet (Urgent)
Hai
i am using an servlet to download files.
i am facing an problem with that servlet.While downloading, at times it strucks at 290k or 330k.
Note : Acually i am calling this servlet from a popup window.The popup window closes automatically after one minute irrescpective of the download progress.At times i noticed that the download strucks while the popup closes, whether is causes the problem of strucking.
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Download extends HttpServlet {
HttpSession session =null;
File F;
BufferedInputStream fif;
ServletOutputStream stream;
public void init(){
F=null;
fif=null;
stream =null;
public void doGet(HttpServletRequest request ,HttpServletResponse response) {
try{
// Setting Buffer size
response.setBufferSize(50000);
// Setting Content Type
response.setContentType("application/x-filler");
int buffersize;
String cfile="";
boolean flag=false;
session = request.getSession(true);
//Receiving variables
String fileName= request.getParameter("filename");
String filePath = request.getParameter("filepath");
String downloadFile = filePath + fileName;
F=new File(downloadFile);
String download_date = "sysdate";
String file=F.getName();
buffersize=(int)F.length();
byte b[]=new byte[buffersize];
//Servet output stream to download file
stream = response.getOutputStream();
response.setHeader("Content-Disposition", "attachment; filename=\"" + file + "\";");
int data;
fif = new BufferedInputStream(new FileInputStream(F));
//writing data to output stream
while((data = fif.read()) != -1) {
stream.write(data);
//closing objects
fif.close();
stream.close();
F.delete();
}catch(java.net.SocketException se){
System.out.println("SocketException " +se);
catch(IOException io){
System.out.println("IOException " + io);
catch(Exception e){
System.out.println("Exception " +e);
}I guess your closing of the window is your problem. Your servlet looks just fine to me.
Try calling this servlet from a browser and see if it still stops.. -
Calling a servlet in java class
Hello,
I try to call a servlet from java class
but is dose not work
what should be the problem
public void callServlet()
try
// xxservlet is the servlet name
URL url = new URL("http://www.mydomain.com/xxservlet");
URLConnection hpCon = url.openConnection();
hpCon.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
out.write("This Is a Test");
out.flush();
out.close();
}catch(Exception ex){ex.printStackTrace();}
// My Servlet is in package servlets
public class XXServlet extends HttpServlet
public void service(HttpServletRequest req, HttpServletResponse resp) {
try {
ServletInputStream sin = req.getInputStream();
int len = req.getContentLength();
byte[] input = new byte[len];
ServletInputStream sin = req.getInputStream();
int c, count = 0 ;
while ((c = sin.read(input, count, input.length-count)) != -1) {
count +=c;
sin.close();
String inString = new String(input);
System.out.println("Servlet is running ...."+inString);
} catch (IOException e) {
try{
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
resp.getWriter().print(e.getMessage());
resp.getWriter().close();
} catch (IOException ioe) {
// web.xml
<servlet>
<servlet-name>xxservlet</servlet-name>
<servlet-class>servlets.XXServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xxservlet</servlet-name>
<url-pattern>/xxservlet</url-pattern>
</servlet-mapping>
}regards
Edited by: the_Orient on Mar 30, 2009 3:16 AMI have start servlet from brwoser only to test that servlet works fine
A gain what I need
I want to call a servlet from a javs class
URL url = new URL("http://www.mydomain.com/myservlet");
URLConnection hpCon = url.openConnection();
hpCon.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
out.write("Hello Woprld");
out.flush();
out.close();// Servlet
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
try {
String xp =req.getSession().getServletContext().getRealPath("/");
File f = new File(xp+"/students/info.txt");
f.createNewFile();
} catch (IOException e) {
try{
resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
resp.getWriter().print(e.getMessage());
resp.getWriter().close();
} catch (IOException ioe) {
problem file can not be created
public void doPost(HttpServletRequest req, HttpServletResponse resp)
}I hope that is clear -
Help needed to call a servlet from an applet
Hi,
can someone help me with the way to call a servlet from an applet.
actually on click of a button i wanna call my servlet and save some data in DB.
i am not able to call my servlet. see the sample code which i am trying..
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().equals("Upload")) {
try {
System.out.println("Upload button has been clicked -----------");
URL url = new URL("http://localhost:8084/uploadApp/TestServlet");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
ObjectOutputStream objOut = new ObjectOutputStream (urlConnection.getOutputStream());
objOut.writeBytes(userId); // pass parameter to servlet
objOut.flush();
objOut.close();
} catch (MalformedURLException ex) {
Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ButtonListener.class.getName()).log(Level.SEVERE, null, ex);
is there any problem with the code? please suggest.hii,
checkout my add from, HTH
[http://forums.sun.com/thread.jspa?threadID=5419921&messageID=10885709#10885709]
... kopik -
Calling One Servlet From Another
Thanks in advance for any advice!
I would like to call servletB from servletA then use the response returned from servletB within the processing of servletA.
I have checked the forums and jGuru but nothing I've found really matches the problem. RequestDispatcher has "forward" and "include" but I do not want to include the reponse from the called servlet in the response of the original one.
Here is the situation. I have a web application that uses an applet front-end using a mainframe datasource. The applet displays data in various JTables and prints various reports.
The applet calls a servlet(B) with an SQL statement in the request that responds with a Vector of data to be displayed in the JTable. This is working fine.
The applet also calls servlet(A) which uses iText from SourceForge to create a PDF report that is sent back to the browser for display in Adobe Reader. This also works fine.
Because I cannot figure out how to call servletB from within servletA, my current workaround is to embed the code of servletB inside servletA. Not very good OOP and as the application grows maintaining this will become a problem.
Any suggestions would be greatly appreciated.
MaxWhy don't you just take the code that the applet uses to "call" servlet B and replicate that code into servlet "A"? (Or better still, create a class to do that, which could be called both from the applet and from servlet A.)
-
If there is a problem starting a servlet....
I'm currently writting an exception handler for my servlet's init() method.
My question is, if there is a problem initialising the servlet (i.e. config files won't load etc) what's the best way to put the servlet out of action?
I'm thinking maybe call the destroy() method within the catch block of init(). Would this be right?
If so what happens if the servlet is shutdown and then there is another request? Will the container (Tomcat) attempt to start the servlet again?
Thanks,When you say "And the container will always attempt to
start the servlet after startup." Do you mean after
shutdown?That's a strange way to say it, but I suppose you might look at it that way. The container shuts down at some point in time. It doesn't attempt to init the servlet then, but after it starts up it does attempt to init the servlet. Either immediately or upon its first use.
It seems a bit strange for the container to keep
restarting a servlet that will always fail on init().How should the container know that? It cannot make any assumptions about what init() might do the next time. Perhaps it failed because the system manager put a configuration file in the wrong place; it might be there now. Basically it's the manager's problem if the servlet init() fails every time, not the container's.
Oh and I don't suppose there is a class constuctor
exception is there, for when a constructor fails?Constructors can throw exceptions if they are designed to do so. -
AJAX calling a servlet's synchronized doPost method
Hi all. This problem has been bugging me for a week already and still no solution in sight...
Anyway, buttons in a page I'm creating uses AJAX to call a servlet's synchronized doPost method. Once a button is clicked, the servlet calls another java class which does some back end processing. Once the called java program is finished running, the page is updated telling the user that the selected backend process has finished running. It works fine if I just run one backend process at a time...however, if try to run another backend process while the previous backend process is still running, even if the backend process is finished, the page doesn't get updated with the message informing the user that the job is finished. The page only gets updated once all the jobs have finished running. What I want to happen is that whenever a job gets finished, the page gets updated.Yeah, it has
something to do with the threads. However, I had to
synchronize the doPost method because if the doPost
method isn't synchronized, running 2 or more back end
processes simultaneously would result in the previous
backend processes being terminated, only the last
back end process would be run successfully.Yea! that's what I wanted to say! most of the time there are critical sections in your code when concurrency is there, you need to recognize them and synchronize only the critical sections.
I don't think synchronizing the whole dopost method is a better way to deal with concurrency issues. It defeats the purpose of spawning a new thread for each request(it's my personal opinion, I may be wrong).
But I got one contradiction from one member of sun forum, he says spawning thread from a servlet is not a good practice according to java EE specification. But I don't think there is any way out other than this, to deal with this scenario. I am waiting for further suggestions, so keep an eye on this thread:
http://forum.java.sun.com/thread.jspa?threadID=5149048
~cheers~ -
Urgent!!!!!!!!!!Calling a servlet setting cookie
Hi,
The following is the complete picture of my problem. I am having a simple java servlet program in my domino server. (regarding the set-up's for executing the servlet program in the domino server....all are through...no problem over there...every thing is done, as per the guidence in the domino administration help).
I want to contact my above said servlet program (in my domino server), from my simple java program (in my client machine). To contact the servlet program from my client machine, i am using the cookie generated by the BROWSER (Internet Explorer), as the entry in to the domino server. But still the servlet program is not getting executed.
As far As the servlet execution from the browser ("http://192.168.10.12:8001/servlet/testing"), the servlet program is getting executed. But If I get the same cookie (DomAuthSessID) from the browser, using the "alert(javascript:document.cookie)"......and try to call the servlet from my java program, the servlet is not getting executed....could u pl. advice me for the above problem.
Thanks and Regards
Subha
Java program for ur reference:(client machine)
import java.io.*;
import java.net.*;
public class authen
public static void main(String args[]) throws Exception
try
HttpURLConnection urlconnection = null;
URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");
urlconnection= (HttpURLConnection)serverURL.openConnection();
urlconnection.setDoOutput(true);
urlconnection.setRequestMethod("POST");
urlconnection.setFollowRedirects(true);
urlconnection.setRequestProperty("Connection", "Keep-Alive");
urlconnection.setRequestProperty("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");
urlconnection.setDoOutput(true);
urlconnection.setDoInput(true);
urlconnection.setUseCaches(false);
urlconnection.setAllowUserInteraction(true);
urlconnection.connect();
catch (Exception e)
e.printStackTrace();
Hope, the way I have called my servlet program "testing" from my client machine is correct.
SERVLET PROGRAM (Which resides in the domino server)
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldExample extends HttpServlet
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
System.out.println("####");
System.out.println("### DOMINO AUTHENTICATION ####");
System.out.println("####");
public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException
System.out.println("####");
System.out.println("### DOMINO AUTHENTICATION ####");
System.out.println("####");
In the servlet.properties file, i have documented as,
# HelloWorldExample properties
servlet.testing.code=HelloWorldExample
servlets.startup=testingTry to replace urlconnection.setRequestProperty
("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");with urlconnection.setRequestProperty
("Cookie","DomAuthSessID=AAE228AB68335546B277E9B375412A8A");Let me know if this solves your problem
BG -
Call a Servlet via POST from a Stand alone Java App
Hi guys.
Right now I am facing a tricky problem I hope you can help me on this...
What I want to do is to call a servlet that is listening ( I can't touch the servlet code) in a web browser.
I was able to send a GET request by a code like this:
URLConnection conn = new URL(webServerStr).openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(webServerStr);
wr.flush();
and everthig was all right.
The problem arises when I try to send a long REQUEST via my java app. I get a 414 HTTP error (414 - Request-URI Too Large ). When I do the long request by browser works fine. (when I fill all the form and press the submit button)
The only difference between the browser request and my java request is the ACTION. From the FORM is POST and when I build the string to send it out to the web server is via GET ( I build the string like ?ATTR=VALUE&ATTR2=VALUE2....)
Here is my question. How I do a POST request from a java application?
Any ideas?
Thaks guys and any help will be appreciate.URL url = new URL("http://localhost:8080/");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setStuff(...............................check out api
con.setDoOutput(true);
con.connect();
// write stuff
PrintWriter pw = new PrintWriter(con.getOutputStream());
pw.println(depart);
pw.flush();
pw.close();
// read reply
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
String res = br.readLine();
Maybe you are looking for
-
[AI-CS5] Unable to capture panel closed/Hide event .
Hi All, I am using flex for my illustrator plug-in panel. I want to show a msg if panel is closed. I registered StateChangeEvent.WINDOW_CLOSE /StateChangeEvent.WINDOW_HIDE in PanelInit() but I am unable to get the call. here is the code that i am
-
How to get all lines in a paragraph?
Hey all, I've got a confusing question, see the codes below: tell application "Adobe InDesign CS4" set doc to open orphan_check tell doc set myPage to page 4 set myTextFrame to first text fr
-
Queries: duplicate info when executing a HR query
Hi. Friends, i trying to do a query with info of two infotipes: 21 and 482 (aditional info of it21), when i execute the query the result it's a cartesian product (wrong result). For example: DATA IT21 PERNR Subty Name 1 10 ssssss 2 11 dddddd IT482 Pe
-
Active directory SYSVOL replication issues
Hello. I have 2 domain controllers, both of them on the same site DC1 & DC2. I have added a new site with a DC3. When I have added DC3 to the domain, I have realized, SYSVOL was not initialized correctly. I went back to DC1 and found out, there's fo
-
Folks, We are looking for some help defining best practice for testing APEX applications. Any pre-written strategy documents available? All and any input much appreciated. Thanks Andy