Servlets :: Explicitly Process JSP From Within Container

Nov 3, 2014

I am looking for a way to have a Servlet (my container is Tomcat) calling a JSP file and processing it in order to retrieve the generated HTML. The compete scenario:

I have virtual shop and whenever a purchase is being carried out, the customer is redirected to a Servlet that post-processes the purchase (list of the items, etc.)

Among all these, the Servlet is also supposed to send me an email about the new purchase. I would like to have nice designed HTML mail and not just a simple plain text notification. I thought of having a designated JSP as a view, and it will only be available from the Servlet container, for this purpose. One way is having the Servlet create an HTTPClient (or any other method of network communication) to my own host and ask for the JSP.

I wonder if there is a simpler way to ask my own container to process a JSP, since I am not really making a request to an outside web application. Something like getServletContext.processAndReturnJsp("mail.jsp")

BTW, if you think my approach is too cumbersome to fill an email with HTML code, it would be great to know of a simpler way.

View Replies


ADVERTISEMENT

Servlets :: Form Based JAAS - How To Implement Login System Explicitly Outside Container

Jan 30, 2014

I have configured form based JAAS in my app. Basically, in web.xml I have declared security constraints on certain jsp page, declared specific roles, login and error pages. So, my login form is:

<form id="loginForm" action="j_security_check" method="post">
<p>
<label for="name">Username</label> <input name="j_username"
id="username" type="text" required/>

[Code] ....

This works fine when some user tries to access some of the pages declared in <security-constraint> tag of web.xml.

Container automatically manages login process, redirects to login page and if login details are valid, gives access to secured page.

Now, how should I implement login system so that user can go to login page (possibly same login form) and log in from there?

View Replies View Related

Servlets :: Process Both Get And Post Requests

Jun 9, 2014

I've written an HTTPServlet that send an HTTP request to one HttpListener and receive POST requests from an Http Sender.This is the code:

package sspa.huvr.git;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;

[code]...

but when is called from the doPost method it seems that the html content is not sent from the processRequest method.

View Replies View Related

Super Keyword When Used Explicitly In A Subclass Constructor

Jul 9, 2014

The super keyword when used explicitly in a subclass constructor must be the first statement but what about if i have a this(parameters) statements ? As the this one must also be the first statement... Does this means that i can have only one or the other ? What about when the super constructor is not explicit (aka implicit ) , can i use the this( parameters) in the same constructor ?

View Replies View Related

Error - Class Name Only Accepted If Annotation Processing Is Explicitly Requested

Apr 20, 2014

This is my first java program.

public class Myjava
{
public static void main (string args[]) {
system.out.println("hello java world");
}
}

I am getting the below error in cmd when compiling the program with command javac Myjava

Error: class name are only accepted if annotation processing is explicitly requested.

View Replies View Related

EJB / EE :: How To Tell Container To Rollback Transactions

Mar 20, 2009

My requirement is to rollback a Transaction which acts with (REQUIRED) Transaction Attribute .

How can i tell the container to rollback a transaction when using with CMT in EJB3.0 ...

View Replies View Related

Implement Type Of Container

Mar 15, 2014

I want to implement a kind of "container" in which to store objects (instances) of different types. Then with an iterator I'd call common methods. This is what I have in mind:

Java Code:
with(Positionables){
translate(2, 0, 4);
} mh_sh_highlight_all('java');

Where translate(x, y, z) is a method common for objects in Positionables which objects are of different types (Sphere, Box etc.).

Now I was thinking Positionables could be a List<Positionable> and Positionable is an abstract class and Sphere and Box extends from it. But I don't know how to propagate the call of translate() to the subclasses.

What are the best approaches for this matter? It would be perfect if I could make it so I could somehow use the "with" construction like in the example above.

View Replies View Related

Swing/AWT/SWT :: Why Must All Components In A Container Have The Same Alignment

Dec 10, 2014

I have a JPanel with vertical BoxLayout. It contains four components. I set the JPanel to LEFT_ALIGNMENT, which has no effect on its components. I set the first component to LEFT_ALIGNMENT, which has no effect. Only after I have set all four components to LEFT_ALIGNMENT do any of them align properly.

This suggests that it is impossible to have varying alignments in a container. They must all be the same alignment.

I accept that this is just the way things are: "Java works in mysterious ways." And I'm sure that it is possible to work around this limitation by stacking boxes that themselves have different internal alignments.

But I still wonder what in the world was going on in the minds of the Java developers. Is there a rational reason for this oddity?

This raises my most serious criticism of Swing: the hidden gotcha. Swing is a tangled mess of cross-connecting requirements that are impossible to divine by simple inspection of the documentation. If you want to use, say, a JRadioButton, it's not enough to study the documentation on JRadioButtons; you must also consult lots of documents for which there is no obvious connection to JRadioButton other than it being part of Swing.

View Replies View Related

Swing/AWT/SWT :: How To Use Container Order Focus Traversal Policy

Feb 1, 2014

the focus traversal policy (hereafter "tab order") in forms and panels doesn't follow the order in which controls were inserted into the container, but is derived from the position of the components on the form or panel. This is very neat (and probably allows sloppy coders and GUI builders to exist without actually ever thinking about the tab order), except when it isn't. As when you actually want to specify a different component order, for example.

In the following example, I've created a form with two columns of buttons. I want the tab order to go through the first column of buttons, followed by second column of buttons (ie. a column-by-column schema). The default tab order is row-by-row, however, and can be obtained for reference by commenting out the setupFocus() call in the constructor.

I had hoped that the ContainerOrderFocusTraversalPolicy would do the job, but there is a couple of problems (which I've addressed in the setupFocus() method). Firstly, the container itself is part of the focus chain. This at least is easily remediable by calling setFocusable(false), but I don't have to do that with the initial focus traversal policy, so I wonder why I have to do it with this one. The other problem is more pressing, though - the ContainerOrderFocusTraversalPolicy lets me (un)hapilly tab through JLabels. Again, I've fixed this, but the initial policy knows all by itself that it's not a good idea to focus a JLabel. Moreover, I'm afraid there might be other components that do not receive focus with the original policy, but ContainerOrderFocusTraversalPolicy might plod though them.

isn't there some focus traversal policy implementation that I could just set and it would tab through exactly the same components as the original policy, except it would order them according to their order in the container?

Code:

package test;
import java.awt.Component;
import java.awt.ContainerOrderFocusTraversalPolicy;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;

[code]...

View Replies View Related

JFrame Container - Unknown Class Error But Codes Looks Ok

Sep 2, 2014

I got stuck with the error "Unknown class" with the code that I copied from the book ...

import javax.swing.*;
class SwingDemo
{
// create a new JFrame container
JFrame MAIN_FRAME = new JFrame ("A Simple Swing Application");

// give the frame an initial size
MAIN_FRAME.setSize(275, 100);

// terminate the program when the user closes the application
MAIN_FRAME.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

[code]...

The error comes from lines 21 and 27.

21 MAIN_FRAME.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
27 MAIN_FRAME.add(FIELD_LABEL);

I have tried to rewrite from scratch and still gets the same error.

View Replies View Related

Web Services :: URI Mapping - Container Always Decides To Match It To Path

Dec 7, 2014

So, i got the following code:

@Path("{bill-id}/request")
@Path("{user-id}")

and the following pattern

myhost/c15a856/request

somehow, the container always decides to match it to @Path("{user-id}"). How do I resolve this

View Replies View Related

Created New Project At Eclipse With Code Pasted Inside DomApli Container In Java File

Aug 11, 2014

I created a new project at eclipse with this code pasted inside a domApli container in a java file, I tried to run it but it wont work,

package domApli;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Prg2 extends JFrame implements ActionListener{
JLabel lblNom;
JLabel lblEdad;
JTextField txtNom;

[code]...

View Replies View Related

Enterprise JavaBeans :: Does Container Managed Entity Manager Is Thread-safe In Stateless Session Bean?

May 8, 2014

I read JEE6 doc and confused with : Does container managed entity manager (injected by PersistenceContext annotation) is thread-safe in stateless session bean in multiple-thread env?
 
See code below, if there are 2 requests to stateless sesion bean in 2 concurrent threads ,  is it using same Entity Manager Instance or not?
 
@Stateless(name = "HRFacade", mappedName = "HR_FACES_EJB_JPA-HRFacade-HRFacade")
public class HRFacadeBean implements HRFacade, HRFacadeLocal {
    @Resource
    SessionContext sessionContext;
   
    @PersistenceContext(unitName = "HRFacade")
    private EntityManager em;
 
[Code] .....

View Replies View Related

How To Communicate Two Process

Aug 5, 2014

I didn't ask you to do my home work . tell me how to communicate two java program using named piped concept.

View Replies View Related

Application Build Process

Mar 15, 2014

I need a summary of the steps involve in building java application.I have my source code, already compiled but I don't know the next step to make it run on a particular device. I know of emulator but I need more information.

View Replies View Related

JAX-WS - Process ID Of Web Service Request

Aug 22, 2014

I am using JAX-WS to develop web services.
 
I would like to know how i can find the process ID associated to a request.

View Replies View Related

Read And Process File Using Thread?

Nov 4, 2014

I created a main class called X and two Y and Z classes.

Y and Z implements Runnable classes.

class X contains a static array A that can be accessed in Y and Z.

The Run () method of the class Y reads an input file and populates the vector A.

The Run () method of the Z class uses data stored into the vector A to process some data.

The objective of using threads in this problem is: as the vector A is filled in the Run () method of class Y, the Run () method of the class Z will processing the received values ​​in the vector A.

to do this I did the following calls in the main method of class X:

ObjectY y = new Y ();
Thready thread = new Thread (objectY);
threadY.start ();
ObjectZ new Z = Z ();
Threadz thread = new Thread (objectZ);
threadZ.start ();

is that correct? I'm getting the expected results, but dont know if the code is parallelized in fact.

View Replies View Related

How To Add Shipping Address During CheckOut Process

Apr 21, 2014

I'm Fresher and i'm new in ATG nd right now working on checkout module.Here I'm trying to take shipping information of user so it is fetching in the shipping information JSP bt when i'm trying to submit that JSP den it's not going to either in SuccessURL or in ErrorURL it's remaining in current JSP.

I'm doing any customization's i'm jst using al Out Of Box Components nd my code is almost same as Out Of Box Code and it is not giving any error also.

I'm attaching my JSP's

Attached File(s)

shipping_jsp.txt (4.17K)
Number of downloads: 293
 shippingAddress_jsp.txt (1.9K)
Number of downloads: 135
 shippingSingle_jsp.txt (70bytes)
Number of downloads: 19
 shippingSingleForm_jsp.txt (2.05K)
Number of downloads: 102

View Replies View Related

Ending Process Of Another Running Jar File

Apr 16, 2015

I am working on a management gui for a program. I have implemented the start server button. But now I need to get something working so that when I press stop server the javaw.exe process which is running the the other jar file is stopped and ended.

The gui is going to be using a javaw.exe as well and I don't want to end the entire thing.

I just want to end the javaw.exe process that is running the other jar file.

This is my code for starting it:

JButton btnNewButton_2 = new JButton("Start Server");
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Runtime rt = Runtime.getRuntime();
try {
Process pr = rt.exec("java -jar DEDServer_release.jar");

[Code] ....

I just need to figure out what to do to stop it now.

View Replies View Related

How To Process / Parse XML Data In Java

Jul 28, 2014

I'm just starting out with learning how to process/parse XML data in Java, following online code/tutorials. I am currently only printing out "catalog."

XML File that I'm trying to read: URL...

import java.io.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

[code]...

View Replies View Related

Input / Output Using Process Class?

Jun 6, 2014

I want to do basic input/output using Process class. I basically wish that, I should ask user his name and when user provides his name then I would print "Hello '[name]'"

import java.io.*;
public class ReadAndPrintName
{
static Process p;

[Code]....

View Replies View Related

Applets :: Start Some Process On Windows

Feb 23, 2014

I have an applet and start some process on Windows from applet. When I start this process just from another code(test), this code works fine and process runs from rt.exec() to proc.destroy(). When I use html call for applet - process runs only for 5 seconds every time (!!!) and then just alive, doesn't work, to proc.destroy(). This is really interesting for me (newbie in applets). I think, this issue caused by AccessController. I use Windows, medium Java security lever and applet is self-signed. It asks me to 'allow', applet works.Here's the code:

public String startRecording(final String filename) throws IOException {
try {
return (String) AccessController
.doPrivileged(new PrivilegedAction<String>() {
public String run() {
try {
proc = Runtime
.getRuntime()

[code]....

It's FFMPEG process, which records desktop video and writes it to file, maybe AccessController blocks access to file system.

View Replies View Related

RMI :: Using RMI To Wrap A Process That Is Not Thread Safe

Apr 3, 2013

I have a multi-threaded application but one function (A) I need to call, that is provided by a third party, is not thread safe. I need to make parallel calls to function (A) so my only option is to start multiple process that I can call from each of my main applications threads.

To do this I created a RMI interface between a the client and the remote process. On the server side I start multiple processes each assigned a different port. On the client side I have a queue manager that connects to the processes I started and builds a queue of them. It passes the client to the threads as needed so they can function in parallel.

I am new to Java development and have the following questions:

1. Each of the server processes require an init function to be run before providing the service. How do I setup the server processes to continue to run in memory listening for a a service request after running the init processes.

2. Is there a better implementation of what I am trying to do?

View Replies View Related

Having Global Variable In Java Associated To A Process?

Aug 22, 2014

Is there a way to have global variable in Java associated to a process ?
 
I'm coming from PL/SQL world, I'm looking for something like package variables.

View Replies View Related

Process To Use Java SE API In Netbeans While Creating GUI?

Mar 3, 2014

I would like to use java se api names like, undo, redo, stylededitorkit, htmleditorkit in editorpane swing. So, I don't understand how to use these apis.

View Replies View Related

XML :: Process Big XML Files And Mapping To Objects

Dec 1, 2014

We need to process (read and parse) big xml files (500 Mo to 1 or 2 Go). What's the best framework or Java library to use for this requirement ? Then what's a good OXM (in this case xml to object mapping) solution for this kind of file ?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved