servlets

Passing custom Objects from applet to servlet

天大地大妈咪最大 提交于 2020-01-05 05:49:05
问题 I have a servlet and i want to pass through UrlConnection some objects. When I tested it, it worked fine. When I passed Java native objects ( String , File ..). But when I try to pass my own Object (instance of my own Class), Object is sent into Servlet correctly via ObjectOutputStream but when I wanted to restore object in servlet side it doesn't work. it throws exceptions that My class was not found. I have MyObject class in project with applet where is loaded and sent to servlet and then i

GWT FileUpload with Servlet

折月煮酒 提交于 2020-01-05 05:36:21
问题 I try to make a very simple GWT-Application: The User can choose a txt file an upload it to the Server. Later I want to implement more functionality but for now I'm stuck on the FileUpload: On the client Side I have the following Code working: public class GwtDemoProject implements EntryPoint { private static final String UPLOAD_ACTION_URL = GWT.getModuleBaseURL() + "upload"; private FormPanel form; private Label info; private FileUpload fileupload; private Button uploadFileBtn; public void

How to pass an object from a java class to servlet?

为君一笑 提交于 2020-01-05 04:49:26
问题 I am using Apache's HttpClient to call a servlet from a Java class. I want to send an object to the servlet which should save the object using Serialization. How to send the object to the servlet? public static void main(String[] args) { Names names = new Names(); names.setName("ABC"); names.setPlace("Bangalore"); HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://localhost:9080/HttpClientPractice/FirstServlet"); //Rest of the code In the above code snippet

Servlet, JSP, JavaBeans and HTML form

假如想象 提交于 2020-01-05 04:42:38
问题 I'm working on a servlet that makes a connection to a database gets the information of one of the tables ans sends this information to a jsp file. This file will print on the brower the information table, adding radio buttons that allows us to choose one of the rows. The servlet looks like this: List<InfoBean> items = new ArrayList<InfoBean>(); if (!conexion.isClosed()){ Statement st = (Statement) conexion.createStatement(); ResultSet rs = st.executeQuery("select * from lista_audio" ); while

How to return an json Object and catch in in Ajax call in HTML

你离开我真会死。 提交于 2020-01-05 04:40:05
问题 I have a simple tree structure of information in my D3 code. The D3 script is calling json from the script d3.json() function and the resulting json is giving the tree structure data.Now I have a couple of information that will come from database and hit the Servlet. I have to make the json dynamically in the Servlet so that it can change upon user response.Here is the script & the json I used.. This is my HTML file from where I made an Ajax call to the Servlet. The Ajax is calling the

First Hibernate project where to place addAnnotatedClass()

戏子无情 提交于 2020-01-05 04:34:15
问题 Hello all I'm trying to build up my first Hibernate project for a Web app, but i'm having some issues Trying to find out where to place the method: AnnotationConfiguration config = new AnnotationConfiguration(); config.addAnnotatedClass(Object.class); config.configure(); i have some java beans decorated with annotations, shel i just insert it in the same class there the bean is? Thank you 回答1: Ideally, you'd call this only if you are developing a standalone application. In a Java EE

AppEngine Multiple User Credentials in Development Server

爱⌒轻易说出口 提交于 2020-01-05 04:05:35
问题 When auth-constraint is specified in AppEngine Development server web.xml file. The User injected to endpoint and User received from UserService.getCurrentUser() in HttpServlet are different. The user Id for endpoint user is zero and for HttpServlet it is a fixed number. When the auth-constraint tag is removed from web.xml file, both user ids are zero. But this tag is required for production server. How to get a single user for development server? <security-constraint> <web-resource

Is there a way to check if I'm inside a servlet request with Guice?

回眸只為那壹抹淺笑 提交于 2020-01-05 03:32:14
问题 I'm writing a JUL logging Handler and I'd like to augment the logged messages with information about the current request, if we're currently handling a request. To accomplish this, I've injected a Provider<Thing> into the Handler , where Thing is @RequestScoped . However, calling provider.get() throws an OutOfScopeException if the logging happens while we're not handling a request. I feel like catching the OutOfScopeException would be bad form. Is there a better way to determine whether or

JSON, Servlet, JSP

十年热恋 提交于 2020-01-05 02:28:13
问题 Firstly, my HTTP POST through a URL accepts 4 parameters. (Param1, Param2, Param3, Param4). Can I pass the parameters from the database? Once the URL is entered, the information returned will be in text format using JSON format. The JSON will return either {"Status" : "Yes"} or {"Status" : "No"} How shall I do this in servlets? doPost() 回答1: Just set the proper content type and encoding and write the JSON string to the response accordingly. String json = "{\"status\": \"Yes\"}"; response

Execute or Run application with java Runtime() or Process Builder

二次信任 提交于 2020-01-05 01:31:21
问题 I'm trying to execute applications from java servlet . When I run it on eclipse integrated tomcat its working fine. When I'm trying to do the same on os integrated tomcat server by deploying .war file into webapps, its not working. It doesn't encountering any error as well. Even I checked the logs, there is no error nothing but usual tomcat access log. Is there any other ways that I can execute applications like firefox, chrome, gedit etc. Note: Basic bash commands like ls, chmod, mkdir were