Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Browser.setUrl(String, String, String[]) not sending post data(That method does not send POST data properly)
Browser.setUrl(String, String, String[]) not sending post data [message #1696785] Thu, 28 May 2015 14:37 Go to next message
Pepe Lotas is currently offline Pepe LotasFriend
Messages: 2
Registered: May 2015
Junior Member
Hi!!

Using the "setUrl(String, String, String[])" function in the "org.eclipse.swt.browser.Browser" class does not send POST data

I have a class with this code:

public class PruebaPost {

	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(2, true));
		
		final Browser browser;
		try {
			browser = new Browser(shell, SWT.NONE);
		} catch (SWTError e) {
			System.out.println("Could not instantiate Browser: " + e.getMessage());
			display.dispose();
			return;
		}
		GridData data = new GridData(GridData.FILL_BOTH);
		data.horizontalSpan = 2;
		browser.setLayoutData(data);
		
		browser.setUrl("http://localhost:8080/test/test.jsp?paramOne=One&paramTwo=Two");
		//browser.setUrl("http://localhost:8080/test/test.jsp","paramOne=One&paramTwo=Two",null);
			
		shell.setBounds(10,10,600,600);
		shell.open();
		
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();
	}	
}


I have an Apache tomcat with the "test" project, with the "test.jsp" page, which just has inside something like:

Param One:<input type="text" value="<%=request.getParameter("paramOne")%>"/>
Param Two:<input type="text" value="<%=request.getParameter("paramTwo")%>"/>


When I launch it, it works flawlessly, however, when I change this lines:

browser.setUrl("http://localhost:8080/test/test.jsp?paramOne=One&paramTwo=Two");
//browser.setUrl("http://localhost:8080/test/test.jsp","paramOne=One&paramTwo=Two",null);


so the data is sent using POST method, it does not work, I mean, the "test.jsp" page is called and it loads, but, the params are null.

I use "httpanalyzer" as a http traffic sniffer, and I can see there that the parameters are being sent!!! It is SO weird!!

I tried it using:


  • Eclipse Helios (which uses the "org.eclipse.swt.win32.win32.x86_3.6.0.v3650b.jar")
  • Eclipse Luna (the latest release, which uses "org.eclipse.swt.win32.win32.x86_3.103.2.v20150203-1351.jar")
  • Eclipse 3.2 (which uses "org.eclipse.swt.win32.win32.x86_3.5.2.v3557f.jar") but this one does not support POST data


However, I tried this example here:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet330.java
And it does work... but that is not a JSP, it is a CGI...

Is there a way I can use it receiving through POST the parameters in a JSP ?

Thaks a lot in advance!!

[Updated on: Fri, 29 May 2015 06:43]

Report message to a moderator

Re: Browser.setUrl(String, String, String[]) not sending post data [message #1696896 is a reply to message #1696785] Fri, 29 May 2015 09:27 Go to previous message
Pepe Lotas is currently offline Pepe LotasFriend
Messages: 2
Registered: May 2015
Junior Member
I answer myself:

I needed to add a header, so this:
browser.setUrl("http://localhost:8080/test/test.jsp","paramOne=One&paramTwo=Two",null);

should be like this:
browser.setUrl("http://localhost:8080/test/test.jsp","paramOne=One&paramTwo=Two",new String[]{"Content-Type: application/x-www-form-urlencoded"});


Now it works like a charm!!

Previous Topic:SWT browser not rendering until shell resize on mac
Next Topic:Right approach to enable SWT hardware acceleration
Goto Forum:
  


Current Time: Sat Jan 23 17:30:17 GMT 2021

Powered by FUDForum. Page generated in 0.02458 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top