JSP :: Using SetAttribute For Sending Parameters To Servlet?
Apr 15, 2015
Im coding like this:
<% request.setAttribute("from", new String("test"));%>
And the I try to send the "from" value to my controller like this:
<p><a href="UserController?action=listNoDeletedFilterdUsers&from=<c:out value="${request.getAttribute('from')}"/>">
Eliminar usuarios por rango de fechas</a></p>
When I press the link and chech the HTML generated it looks like this:
<p><a href="UserController?action=listNoDeletedFilterdUsers&from=
It is not getting the value of the request which I suppose is been set at the setAttribute line of code.
View Replies
ADVERTISEMENT
Mar 12, 2014
I am building an online quiz. I created a database , bean , controller and jsp. I connected database, wrote query , put resultset in arraylist of object and passed it to jsp. My program runs but arraylist size increases everytime and same question get displayed repeatedly . i cant find the error. Everytime i run the program arraylist size increases. I think it is adding same rows again ang again. here is my code for controller and jsp.
servlet code:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
[Code] .....
View Replies
View Related
Sep 12, 2014
I'm trying to pass a parmeter to a jsf page from a servlet(i.e. associated with paypal adaptive api), but I keep getting the following error, even though the productType on ProductDetailsVO is a String.
INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=j_idt2[severity=(ERROR 2), summary=(j_idt2: '45;productType=Sport'
must be a number consisting of one or more digits.), detail=(j_idt2: '45;productType=Sport' must be a number between -2147483648 and 2147483647 Example: 9346)]
Calling JSF page contains:-
returnURL = new URL(new URL(request.getRequestURL().toString()),"pages/paypalpaymentapproved.xhtml?paypalID="+paypalID+";productType=Sport");
response.sendRedirect(returnURL.toString());
[Code] ....
View Replies
View Related
May 23, 2012
I'm trying to create a Servlet that takes input from a form and process it and insert it in database.tablename.
My MAIN ISSUE IS WITH THE NUMBER OF COLUMNS THAT WOULD BE DYNAMIC AND THUS CANT RECEIVE THE PARAMETERS IN STATIC CODE.
Here is the form code
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<form action="Test" method="post" />
<table width="90%" border="1" cellspacing="1" cellpadding="1">
[Code] ....
And here is the Servlet
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.io.*;
public class Test extends HttpServlet {
[Code] ....
This is the basic code structure and I'm trying to figure out this special case with handling the multiple parameters:
I don't want to use String []a=request.getParameterValues("studentname"); as hard code. The reason being the number of rows will be diyamic and I would like to get the column name and then then use an array of string to take values. But how can I connect these to form a query so that the rows goes on inserted one after other.
View Replies
View Related
Sep 6, 2014
I have a WebView which displays a site. At a specific page I want to fill in some values into <input> elements. So i use such an event handler (browser is of WebView class)
browser.addEventHandler(MouseEvent.MOUSE_CLICKED,
new EventHandler<MouseEvent>(){
public void handle(MouseEvent e) {
Document doc = webEngine.getDocument();
if (doc == null) {
System.out.println("Doc is null");
[Code] ....
The handler sets the "value" but view doesn't reflect that, field is empty.
View Replies
View Related
Apr 17, 2014
I have two programs that I'll post below, one is a Server and the other is a Client. The ChatServer runs once and many clients can run ChatClient from separate computers and talk together in their GUI's. The the client program comes with two buttons, one that's simulates the sending of a message to a single user ; "Send Message To User", and one that just generally sends a message ; "Send Message To All". Although now the Clients on the server seem to be able to selectively send messages to an individual by giving the recipient name, all the clients can see that message, which is not exact what I am aiming for. What I am going for is having the "Send Message To User" button click to send a message to the named user without all other users seeing the message.
The Server Program Code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
[Code] ....
Now I have tried thing like having various input output streams and trying to connect those, but no luck. Tried fiddling with having the names arraylist directing the messages to one client versus all but that did not work out either. How I what I would need to do to go about doing this?
View Replies
View Related
Jan 23, 2013
I am a beginner want to compile servlet with following path
javac -classpath Program FilesApache Software FoundationTomcat 5.5commonlibservlet-api.jar;classes:.-d classes srccomexamplewebBeerSelect.java
Problem arises as follows:
javac: invalid flag: FilesApache
Usage: javac <options> <source files>
use -help for a list of possible options
View Replies
View Related
Jul 7, 2014
I have a server with a handful of php services. I communicate with these services by creating connections from java code. The services currently respond with XML, but that can be changed if an alternative way can improve performance.
One of the things I need to do is send varying sized payload (some large) to one of the services. My current plan is to create an xml file in java and perform a POST request with the XML as the payload. I am using an XML because the data is very structured.
From a performance point of view, would it be better to send the XML as a file or just as text? Also, is there a better way to send this data? These services will eventually be used by an android app, where performance and minimizing the size of the data packages will be extremely important.
View Replies
View Related
Jun 13, 2014
I did this using ArrayList<String> and my tests worked. Meaning I was able to read the strings in a different class through my constructor. However I want to use a string array because it will be easier to handle when I finish the program. I will send each players poker hand in and figure out who is the winner instead of putting it all onto a ArrayList and having to iterate through it. However whenever I did my check I am just printing null.
PokerFile class
void separateHands(String cards) {
//ArrayList<String>playerOne = new ArrayList<String>();
//ArrayList<String>playerTwo = new ArrayList<String>();
String[] playerOne = new String[10];
String[] playerTwo = new String[10];
[Code] .....
ignore the boolean methods I was just building the structure of the program. The print file is what is outputting this:
null
null
null
null
null
null
public class WinningHand extends PokerFile {
//ArrayList<String> p1 = new ArrayList<String>();
//ArrayList<String> p2 = new ArrayList<String>();
String[] p1 = new String[6];
String[] p2 = new String[6];
WinningHand(String[] p1,String[] p2)
[Code] ....
View Replies
View Related
Dec 23, 2014
New to SMSLib. I checked some samples and docs but did not get any ref/poc wherein I can send SMS with following set-up.
1. I want to send SMS from PC which is connected to internet in office network, where I am using proxy settings to connect to internet.(Basically office PC used in LAN environment)
2. I am not sure how to set the Modem settings in this scenario.
3. What i want - want to test SMS functionality in office environment and would like to send SMS to android based mobile using SMSLib library.
4. I have done SMSLib set-up on my PC and have all the required jars/dlls placed at proper location. So no issues related with set-up. Set-up is on windows platform.
5. I have written sample POC by referring some blogs/SMSLib docs. But as mentioned in points 1 and 2 above, am not getting how to write the code.
View Replies
View Related
Dec 15, 2014
I am trying send email .So I have downloaded javaEE and javamail jar files and added buildpath.And wrote this code below .But I am getting this exception.
Exception in thread "main" java.lang.RuntimeException: javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbskV
534-5.7.14 ggcPi6MBZ4h8CCyCk2TG9EhiTGyE5MVBv7B3k7DsCldqjCuFvMTQG6aAbatrAWggH29muG
534-5.7.14 dzVh1kUYgMgNHAN558QRCnTjrNtUGv34Ul4pzUaansBuBfB0Kpz6_q7JTbrUuAmlZplouA
534-5.7.14 AHDXpFtuCkd-W17tHrZS5mqgVVxAcuKc-7TkhCDGShnfRBWU2R8v-gfvIQShszqsZmCl0i
[Code] .....
What am i missing here.
public static void main(String[] args) {
final String username = "mymail@gmail.com";
final String password = "mypass";
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
[Code] .....
View Replies
View Related
Feb 20, 2014
I am new to java (been Reading for 2 days now), and have almost no knowledge on programming (I am a Mechanical Engineer).The problem I have is that I have to upload 5,000 files to a web page (each one is name B001400XXXX.pdf in consecutive order).I have managed to access the web page and select a few form elements using watij, but I am having a hard time sending my pdf file to the server. This is what I have so far:
Java Code:
import org.watij.webspec.dsl.WebSpec;
public class NewClass {
public static void main(String[] args) {
[code]....
View Replies
View Related
Sep 15, 2014
I need to send a byte array across a network. I know how to do this. (server->client)
byte[] myArray = new byte[]{0,1,2,3,4,5,6,7,8,9};
DataOutputStream.write(myArray);
... and I know how to receive it.
byte[] myArray = new byte[10];
DataInputStream.read(myArray);
When I send over one of these arrays, it ends up stopping storing values in the array when only about half the array is received, even though the array is sent from the server all at once. This results in the receiver's array, in this case, being something like {1,2,3,4,0,0,0,0,0,0}.
I can easily solve this - and already have - by simply adding a loop onto it and waiting for the bytes to all be received, as the method returns the amount of bytes actually read.
byte[] myArray = new byte[10];
int bytesRead = 0;
while( bytesRead < myArray.length) {
bytesRead += DataInputStream.read( myArray, bytesRead, myArray.length - bytesRead );
}
I am simply wondering if there is a better solution to this, as the current solution isn't that elegant. Did I do something wrong to cause only a part of the array to be sent first? Would it be better to use DataInputStream.readByte() to read off the bytes one by one rather than an array at once, and then store them in an array afterward? Would this cause a performance decrease as each byte is read individually? (I'm sending an array of several million bytes)
View Replies
View Related
Jan 23, 2014
I want to send email from my jsp file .. And I have a html code which contains form and inputs. How can I send the email? And I am using netbeans ..
View Replies
View Related
Apr 16, 2015
Say I was to make a computer game, the first person to play the game would have a joinable game and would then be the server, and anyone joining in would be the client and the server was updated with JSON data of the clients computer game, and the server would then update each client of each characters new data using JSON, I would need fast multi threaded connection handling with minimum overhead, Is there a specific way to do this? or are there many?
I have realized there are a few ways to send and receive data using UDP and while experimenting I have also found its quite hard to synchronise.
Do I have a connection listening until there is data to be sent and then switched back to listening?
Do I have the server listening for a microsecond and then checking to see of there's anything to send for a microsecond continuously?
Do I have multiple connections for sending and receiving
Do I create new connections for each new and individual packets to be sent and received dynamically on a thread?
What is the optimum most effective way and do my examples reflect much understanding at all? my resent attempts create new problems and rather than re invent the wheel I would like to know what is normally done.
View Replies
View Related
Sep 3, 2014
Java code to send sms through gsm modem using AT commands..
View Replies
View Related
Jul 9, 2014
I have a simple class, called InputManager, which has methods that communicate with another class DatabaseManager which has access to Database which is actually object that contains information about actual database.
My JFrame has Navigation class (extends JPanel). There I put all needed JButtons, JLists and so on.. This class has instance of InputManager and when user interacts with GUI components inside of it, Navigation calls InputManager methods, it then analyses the call and calls needed methods on DeviceManager, which then sends queries to Database and etc.
The problem is, that at the beginning (when user runs a program), I want to get information (which is actually values for my GUI components ) from Database. It could, for example, create another DatabaseManager and connect to the Database to get information, but it is okay to have two objects?
I was also thinking about sending same DatabaseManager object through InputManager to Navigation, but it seems strange for me to have two objects, which can interact with each other in both directions(Class A has instance of Class B, and Class B has instance of Class A). Is there anything bad this can do?
Also what I noticed that it seems odd that GUI class would have to get information from database. (Logic in GUI class).
View Replies
View Related
Mar 26, 2014
i am having a below piece of code in my worker thread. In my output i am getting xml records from the database. I'm sending this output to a input stream & finally to a sax parser.My query is, before sending to the parser i need to store the input stream in buffer. The buffer should store 1000 records. For every 1000 records the parser should be called from buffer.
while (orset.next()) {
output = orset.getString("xmlrecord");
writeCount++;
InputStream in = new ByteArrayInputStream(output.getBytes("UTF-8"));
InputStream inputStream = new ByteArrayInputStream(output.getBytes("UTF-8"));
Reader reader = new InputStreamReader(inputStream,"UTF-8");
[code]....
View Replies
View Related
Apr 2, 2014
I've just recently started playing around with network programming in Java, and I've come up with a simplistic server than can handle multiple clients and return the IP and port each one is connected to (or I'm under the impression that is so). What I've been requested to do as an exercise by one of the programming teachers at my high school (I'm not in a class, this is my own time) is send a message from one client to the other through the ServerSocket so that it may "watch" everything going on. I'm not sure how to go about this at all.
EDIT : now it never seems to go the the else or else if statements...
That is now the main problem. It never, ever, goes past the first if statement, no matter what it is.
EDIT : Okay, I haven't changed a line of code but suddenly not a single if statement is working. They just stopped. The client simply hangs and I can't type anything.
Server
public class Server implements Runnable {
Socket clientSocket;
Server(Socket clientSocket) {
this.clientSocket = clientSocket;
}
public static void main(String args[]) throws Exception {
ServerSocket ssock = new ServerSocket(3480);
System.out.println("Listening on port 3480");
[code]....
View Replies
View Related
Oct 8, 2014
I just want to to ask how can I send a form to a servlet using javascript?
Here's my form:
<form id="movieForm" class="form-signin" action="addnewmovie" method="POST"
enctype="multipart/form-data">
<h1 class="text-center movie-title">Add New Movie</h1>
<div class="row">
<div class="col-md-12">
<input id="movieId" type="text" class="input-hide form-control"
placeholder="Movie ID">
[Code] ....
This button will responsible for sending:
<button id="add-new-movie"
class="button-position btn btn-primary btn-block"
type="submit" onClick="submitForm();">Add Movie</button>
Note that I include file uploading in the form.
View Replies
View Related
Apr 20, 2015
package javaanpr.gui.windows;
import java.net.*;
import java.io.*;
import java.util.Scanner;
[Code].....
View Replies
View Related
Mar 4, 2015
I am creating a server that stores application updates. When the client connects the server send the update. The server is sending the file but the file is not complete, i.e, if the file is 317kb,its send 117kb. Below is the code I am using :
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TestFileServer {
[Code] ....
What could the problem be?
View Replies
View Related
Jun 17, 2013
At first, oracle change this site a lot. I logged into this site after a long time and I was amazed to see the new changes. Moving onto the the question.
I am developing a spring mvc web application. The problem is when I send email, let say to more than 4 person, the program hangs for a while. Some friend told me to use thread pool to solve this. What is the general practice for handling this kind of situation?
View Replies
View Related
May 2, 2014
I have two JFrames the first one is a log in screen where i log in to the log in server that i made using RMI . If the log in succeeds i send the user object witch is Serializable to the second JFrame.
The user object is received from the server. This object contains all the information needed in the second JFrame. This second JFrame is made inside the first one and i defined a method with witch i send this user object to the second frame.
Now the problem arises , while inside this method i am able to read all the data i need from the user object. At the end of the method i save the reference of this object in a new User object defined in the second JFrame ,because i need it later on.
But soon as this method finishes , for some reason my reference to the object becomes null , and i cant use it later on.
View Replies
View Related
Oct 6, 2014
I am trying to display a list fetched from DB in a JSP.
My servlet mapping is:
<servlet>
<description></description>
<display-name>DocumentsServlet</display-name>
<servlet-name>DocumentsServlet</servlet-name>
<servlet-class>com.xyz.servlet.DocumentsServlet</servlet-class>
[Code] ...
The code in the servlet is:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Doc> docs = null;
Connection con = null;
[Code] ....
The code in JSP is:
<%
List<WWDoc> completedDocsList = (List)request.getAttribute("completedDocs");
System.out.println("In JSP == "+completedDocsList.size());
%>
The request is not coming back to the JSP page.
If I change the servlet and have "request.getRequestDispatcher("/pages/ViewCompletedWWDocs.jsp").forward(request, response);" un commented, I get exception "java.lang.IllegalStateException: Cannot forward a response that is already committed".
View Replies
View Related
Mar 20, 2014
package signup;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
[Code].....
View Replies
View Related