servlets

Servlets response.sendRedirect(String url) doesn't seems to send the encoding, why?

Hi folks, I have some Servlet that explicity sets the character encoding and redirect to some servlet class Servlet1 extends HttpServle{ void doGet(..... ){ // ... request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"): //...... response.redirect(servlet2); } } clas...

Servlet Session behavior and Session.invalidate

Suppose I have a web app with a servlet defined in web.xml. Then I deploy it on Tomcat. Then I open my browser and go to the link to this servlet, it is invoked. Then I close my browser window. How Session behaves ? How is it created, destroyed in this case? if this servlet is "detached" from all the web app, and gets parameters onl...

Security when using GWT RPC

I have an POJO in Google Web Toolkit like this that I can retrieve from the server. class Person implements Serializable { String name; Date creationDate; } When the client makes changes, I save it back to the server using the GWT RemoteServiceServlet like this: rpcService.saveObject(myPerson,...) The problem is that the user s...

How can I pass init parameters to HttpSessionListener?

When configuring filters, I can pass some values to a filter as initial parameters in web.xml and obtain those values in Filter via FilterConfig. How can I configure some initial parameters in web.xml for HttpSessionListener? If this is not possible, what are alternatives? ...

Problem in getting response from server in jquery

Hello, I'm using $.ajax(options) method to pass the request to server based on username and password, but whenever I try to print the response by XMLHttpRequest object when response gets successful, I'm getting an empty value. $(document).ready(function(){ $("#form").submit(function(){ $.ajax({url:"Chat.jsp",type:"POST",data:$("#form")....

java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest

I'm developing a servlet that receives a multipart request with content of multiple files, and I'm using apache commons file upload libraries. When I call parseRequest(request); method servlet throws following exception: GRAVE: Servlet.service() for servlet DiffOntology threw exception java.lang.NoClassDefFoundError: javax/servlet/http...

Using a Filter to serve a specific page?

Hi, I am using a class which implements Filter for my jsp stuff. It looks like this: public class MyFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.getRequestDispatcher("mypage.jsp").forward(req...

reload a form with the same parameter of the previous

Hi every one, I have really a problem that I don't know how to deal with it. I am using JSP and Servlet with the Eclipse IDE. First of all, the user fill an html table with the values that he has selected and written in the form. after that he will find his parameters displayed in the html table. the problem now is : the table contains...

Java (JSP/Servlet): equivalent of getServletContext() from inside a .jsp

How should I access the ServletContext from a .jsp? For example, how can I call the getRealPath method from inside a .jsp. Here's a Servlet, which works fine: protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { resp.setContentType( "text/htm...

How to set the path to "context path" for uploaded files using Apache Common fileupload?

Hi, I'm using Apache common fileupload library with Netbeans 6.8 + Glassfish.I'm trying to change the current upload path to be in the current context path of the servlet , something like this: WEB-INF/upload so I wrote : File uploadedFile = new File("WEB-INF/upload/"+fileName); session.setAttribute("path",uploadedFile.getAbsolutePa...

pass value to servlet from a hidden input type

I am trying to pass the parameter called value in the hidden input type to my servlet. It is like that: retour.append("<input type=\"hidden\" id=\"id_" + nomTab + "_" + compteur + "\" value=\"" + object.getIdDailyTimeSheet() + "\"/>"); retour.append("<button id=edit name=edit type=submit onClick= editarow()>"); retour.append("<img src=...

the way to get a value from a hidden type correctly

in a html table i construct in each row an edit button like the following: retour.append("<input type=\"hidden\" id=\"id_"+nomTab+"_"+compteur+"\" value=\""+object.getIdDailyTimeSheet()+"\" name=\"hd_"+compteur+"\" />"); this is the hidden type then i do the following: retour.append("<button id=edit name=edit type=button onClick...

Servlet.init() and Filter.init() call sequence

In which order are Servlet.init() and Filter.init() methods called in java web application? Which one is called first? Are all Servlet.init() methods called before than any Filter.doFilter method? ...

How to make Asynchronous(AJAX) File Upload using iframe ?

Hi, I'm trying to make ajax file upload . I read that it is not possible to do that without using iframe . I wrote : <iframe id="uploadTrg" name="uploadTrg" height="0" width="0" frameborder="0" scrolling="yes"></iframe> <form id="myForm" action="file-component" method="post" enctype="multipart/form-data" target="uploadTrg"> File: <inpu...

How Handle session using requestProcessor

Hi, I am working on struts,i want to know how to handle session using org.apache.struts.action.RequestProcessor ? Where in have to check the existence of session throughout the app ? ...

get the right id of a record in database in each click on the edit button

hi every one, i am facing a big problem right now. I have a html table in each row i have a button called edit allowing user to relod the form with parameter that he has selected. for this i define a hidden type to get the id of the record in database to access to various colonne and to refresh the form with those parameters. My challeng...

Servlet mapping url patterns

I have the following urls that need mapping to two different servlets. Can anyone suggest a working url-pattern please? vehlocsearch-ws: /ws/vehlocsearch/vehlocsearch /ws/vehavailrate/vehavailratevehlocsearch /ws/vehavailrate/vehavailratevehlocsearch.wsdl vehavailrate-ws: /ws/vehavailrate/vehavailrate /ws/vehavailrate/vehavail...

how to get the button value from jsp to servlet

hi, how to get the button value from jsp to servlet in jsp: <input type=button name=bt value=gi onclick="document.frm.submit();"></input> and in servlet like that: String gi =request.getParameter("bt"); System.out.print("button value" +gi); result=null thanks ...

JSP Servlets simple question.

What is the simplest way to use a variable in the URL in servlets. Eg. http://somesite.com/MyServlet/[ID] ...

Can I not submit a form to a servlet from JSF?

* Unable to find matching navigation case with from-view-id '/home.xhtml' for action 'MemoServlet' with outcome 'MemoServlet' I try to accomplish it through: <h:commandButton type="submit" value="add" action="MemoServlet"/> but all the tutorials in the world only do it with a bean, which i don't want. I've come across any navigat...