Hi I am making my own web programming with spring mvc. I am very new to java world, java script, all related knowledge in web application. I am using several references and making my own. Now I am trying to do this:
1) open & establish the connection to external web server
2) it will require credentials & provide their credential: username, pw
(succeed & established connection & they, the external web server (the server my program need to connect) will redirect to data page),
3)Then my program retrieve data from them and render the data(s) with whatever fancy tools in jsp file
I have invested and tried 1) & 2) but there haven't been any luck. so can anyone give advice.. here is one of my trial and there are a lot missing part as well.
testController.java
@Controller
public class testController {
//[Q1] Do I need annotation here?
public URLConnection openURLConnection() throws IOException{
ClassLoader classLoader = getClass().getClassLoader();
URL resourceURL = classLoader.getResource("url:http://ift.tt/1AUD4pn");
//[Q2-1] how to set username and password ?
return resourceURL.openConnection();
}
@RequestMapping(value="/retrieve", method=RequestMethod.GET)
public String retriveData(Model model){
//[Q3]here I need to "redirect" their data page and "retrieve" data..
return "retrieve";
}
}
About [Q2-1] in testController.java when I request to open connection, should I set username, password in [Q2-1] location? or should I set username, password in xml like this:
test.xml
<authentication-manager>
<authentication-provider>
<user-service>
<user name="matchingUsername" password="matchingPW" authorities="???" />
</user-service>
</authentication-provider>
</authentication-manager>
[Q2-2] if I use this test.xml for username, password for the external web server credentials. How to couple it with [Q2-1], how to check the connection established (true)?
I am very new.. so explanation like what missing, wrong and why will be really appreciated.
No comments:
Post a Comment